@hiredman Fine! If ./target/classes is correct, config.edn is there which means that, as you say, something is wrong with compiling.
So, how do I ensure that ./target/classes is on the classpath at the clj -T:build uber step?
@wactbprot can you share your build script?
Sure, its more or less the same as in the guide:
(ns build
(:require [clojure.tools.build.api :as b]))
(def lib 'com.github.wactbprot/repliclj)
(def version (format "0.2.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(def uber-file (format "target/%s-%s-standalone.jar" (name lib) version))
(defn clean [_]
(b/delete {:path "target"}))
(defn prep [_]
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis basis
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir}))
(defn jar [_]
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis basis
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file}))
(defn uber [_]
(b/compile-clj {:basis basis
:src-dirs ["src"]
:class-dir class-dir})
(b/uber {:class-dir class-dir
:uber-file uber-file
:basis basis}))
Got it! If I use the top level :path and :deps in my deps.edn everything works fine ๐ How would I include an alias in the command clj -T:build uber?
@wactbprot does -T:alias:build work?
@borkdude No, I have defined the deps and paths in a :dev alias that needs to be considered during the build uber step. However, for this project it is not important to use an alias; I am just happy that it works and curious how to include an alias in the build process.
What is the intent of the alias? To add deps? If so, In the build.clj you can compute a second basis and supply an alias when you do so
@alexmiller it is not important for this project but let's assume I like to add deps via an alias. How would this work?
Like I just said
If you want to parameterize your build program, you can do that too by having your entry point function take the alias to use while making the basis used during uberjaring
There is an example of parameterization in the build guide too
The important thing here is the command you are running at the cli is the build program. In the program, itโs up to you what you do, what deps you use, how the program is parameterized
ok, I see. A big thank you to all of you!
I missed the :aliases option the create-basis function provides. This works fine: (def basis (b/create-basis {:project "deps.edn" :aliases [:dev]})) Maybe it's an idea to add a hint under the "Some things to notice:" section in the guide. Thanks again!
@alexmiller what if you want to add deps to use in build.clj and not as a top level dependency, how would that work?
isn't that the scenario we're discussing?
you're making the basis in the build.clj - if you want it to be something, pass the args to make it whatever you need it to be
I mean, not the basis to use for e.g. building an uberjar, but additional tools like library-whatever to do whatever during the build
I guess just use the :build alias?
https://github.com/seancorfield/honeysql/blob/ec758dd818bf603b6eea2bfe042ff3133e72c93f/deps.edn#L6
That's pretty evident, I guess ;)
Yes
@seancorfield I just came across your code in the comments of https://clojure.atlassian.net/browse/TBUILD-6 and it sparked hope that -X style tasks might be supported in build-clj. Is that on the horizon?
My impression, from talking to @alexmiller, is that some variant of this might end up in some Contrib library perhaps and then I would adjust build-clj to leverage that as needed. I don't want to bake our version in from work because it relies on things that are "unknowable" out in the wild (we vendor the Clojure CLI into our repo so that we can rely on a specific version being available on each tier as we roll out builds so we know where the correct version of exec.jar is on every machine).
(and exec.jar is an undocumented, unsupported, unstable API that could -- and has -- change at will right now)
Does that answer your Q @erp12?
Yup, thanks @seancorfield. It sounds like things are in motion so I will allow my hack to stay a hack. I just want to trigger doc generation on an "prepare-release" entrypoint and (sh "clj" "-X:codox") does the trick.
@erp12 Yeah, in the absence of built-in exec-command style invocation, shelling out to the clojure script is probably reasonable...