I have been dealing with this Clojure/Clojurescript project called clojurescript.csv.
On the project.clj
file there is a special form of construction for :cljsbuild
which I haven't seen yet.
:cljsbuild {:builds [{:id "whitespace"
:source-paths ["src" "test"]
:compiler {:output-to "target/js/whitespace.js"
:optimizations :whitespace
:pretty-print true}}
{:id "simple"
:source-paths ["src" "test"]
:compiler {:output-to "target/js/simple.js"
:optimizations :simple
:pretty-print true}}
{:id "advanced"
:source-paths ["src" "test"]
:compiler {:output-to "target/js/advanced.js"
:optimizations :advanced
:pretty-print false}}]
Usually, I see a brief declaration, such as:
:source-paths ["src"]
On this repository the approach is different. Although each "build path" uses the same source-path
there are different ids and optimizations route.
1 - What is the point on having these different ids for builds? How can this be useful?
I do not see it.
2 - Also, I would like to extend this file for Continuous Deployment (publishing a Maven package on GitHub registry). Usually, below the source-paths
, I add the following:
source-paths ["src"]
;; Change your environment variables (maybe editing .zshrc or .bashrc) to have:
;; export LEIN_USERNAME="pdelfino"
;; export LEIN_PASSWORD="your-personal-access-token-the-same-used-on-.npmrc"
;; LEIN_PASSWORD should use the same Token used by .npmrc
;; Also, do "LEIN_SNAPSHOTS_IN_RELEASE=true lein install" or edit your .zshrc:
;; export LEIN_SNAPSHOTS_IN_RELEASE=true
:repositories {"releases" {:url "https://maven.pkg.github.com/tallyfor/*"
:username :env/LEIN_USERNAME ;; change your env
:password :env/LEIN_PASSWORD}}
:pom-addition [:distribution-management [:repository [:id "github"]
[:name "GitHub Packages"]
[:url "https://maven.pkg.github.com/my-organization/repository-name"]]]
Should I add it 3 times? One for every id?
It feels very repetitive.
lein-cljsbuild
allows you to specify multiple build configurations like this. When compiling you may provide the id of the build you want to build. So, instead of just lein cljsbuild once
you do lein cljsbuild once advanced
.
This is common so you can have an unoptimized development build and a :advanced
optimized release build. Usually you'd have a few more differences in build configs, eg. at least the advanced
build not including "test"
source path. Since this is a library project, this however is fine. The authors likely wanted to test with different optimization levels easily.
:repositories
and :pom-addition
are top level or alias/profile definitions in project.clj
. They do not go into the :cljsbuild
config map.