exclude certain clj namespaces from compilation in leiningen

clojure, leiningen, uberjar

Solution

Have a look at leiningen's sample project.clj, which describes how to use `:jar-exclusions` or `:uberjar-exclusions` to exclude arbitrary paths when creating jars (resp. uberjars).

  ;; Files with names matching any of these patterns will be excluded from jars.
  :jar-exclusions [#"(?:^|/).svn/"]
  ;; Files with names matching any of these patterns will included in the jar
  ;; even if they'd be skipped otherwise.
  :jar-inclusions [#"^\.ebextensions"]
  ;; Same as :jar-exclusions, but for uberjars.
  :uberjar-exclusions [#"META-INF/DUMMY.SF"]

Problem

I have a project that works fine using `lein run`. Now I want to compile it into a standalone jar using `lein uberjar`. However, there are a couple of source files in my `src/projectname/` directory called e.g. `playground.clj` and `stats.clj` that I use for experimenting with emacs & the repl, but that I don't want to compile for the final project. With something like `make`, I would specify all files that should be compiled. With clojure/leiningen, it seems, all files are compiled by default - how can I exclude files? I haven't found anything in the leiningen docs. I am currently using `:aot :all`. Is this the place to change something? Again, I couldn't find detailed documentation on this. UPDATE: The suggestions so far haven't worked. What has worked, however, is to include all desired namespaces instead of excluding the ones that should not be compiled. E.g.: ``` (defproject myproject "version" ;; ... :profiles {:uberjar {:aot [myproject.data myproject.db myproject.util]}}) ```

Original source