-
-
Notifications
You must be signed in to change notification settings - Fork 180
For Cursive Users
Cursive's Leiningen support requires a project.clj
file to be able to discover dependencies
so it can resolve symbols in your source code.
To make sure your build.boot
dependencies are kept in sync with what Cursive sees,
it's recommended to just regenerate the project.clj
every time boot
starts.
The simplest way to do that is to use the boot.lein/generate
boot task from the
[onetom/boot-lein-generate]
micro-library.
There is a reference project showcasing all this: https://github.com/onetom/hoplon-layouts
For further information, follow the related Cursive github issue: https://github.com/cursive-ide/cursive/issues/692#issuecomment-257907140
Adding a lein-generate
task as the one below can generate a project.clj
file on the fly so Cursive knows what to do. And since you will need to use this task in all of your Cursive projects, it works best if you add the following code to your profile.boot
file.
(defn- generate-lein-project-file! [& {:keys [keep-project] :or {keep-project true}}]
(require 'clojure.java.io)
(let [pfile ((resolve 'clojure.java.io/file) "project.clj")
; Only works when pom options are set using task-options!
{:keys [project version]} (:task-options (meta #'boot.task.built-in/pom))
prop #(when-let [x (get-env %2)] [%1 x])
head (list* 'defproject (or project 'boot-project) (or version "0.0.0-SNAPSHOT")
(concat
(prop :url :url)
(prop :license :license)
(prop :description :description)
[:dependencies (conj (get-env :dependencies)
['boot/core "2.6.0" :scope "compile"])
:repositories (get-env :repositories)
:source-paths (vec (concat (get-env :source-paths)
(get-env :resource-paths)))]))
proj (pp-str head)]
(if-not keep-project (.deleteOnExit pfile))
(spit pfile proj)))
(deftask lein-generate
"Generate a leiningen `project.clj` file.
This task generates a leiningen `project.clj` file based on the boot
environment configuration, including project name and version (generated
if not present), dependencies, and source paths. Additional keys may be added
to the generated `project.clj` file by specifying a `:lein` key in the boot
environment whose value is a map of keys-value pairs to add to `project.clj`."
[]
(with-pass-thru fs (generate-lein-project-file! :keep-project true)))
(source)
You can find other developers and users in the #hoplon
channel on freenode IRC or the boot slack channel.
If you have questions or need help, please visit the Discourse site.
- Environments
- Boot environment
- Java environment
- Tasks
- Built-ins
- Third-party
- Tasks Options
- Filesets
- Target Directory
- Pods
- Boot Exceptions
- Configuring Boot
- Updating Boot
- Setting Clojure version
- JVM Options
- S3 Repositories
- Scripts
- Task Writer's Guide
- Require inside Tasks
- Boot for Leiningen Users
- Boot in Leiningen Projects
- Repl reloading
- Repository Credentials and Deploying
- Snippets
- Troubleshooting
- FAQ
- API docs
- Core
- Pod
- Util