Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define our own boot task to make jack-in more robust #1731

Closed
Malabarba opened this issue May 5, 2016 · 5 comments
Closed

Define our own boot task to make jack-in more robust #1731

Malabarba opened this issue May 5, 2016 · 5 comments

Comments

@Malabarba
Copy link
Member

When doing middleware injection in boot projects, we add the cider-nrepl artifact as a dependency by passing the -d argument to boot and we add our middleware to tools.nrepl by passing the -m argument to the repl task.
The -d argument is fine, but the -m argument is a little finicky. It only works immediately after the repl task, so there's nothing we can do if the user instead uses a custom task or something like the very popular cljs-repl task.

Instead, cider-nrepl could define its own boot task that properly adds the nrepl middleware. Then all we have to do is inject the dependency with -d and add the task before any other task in cider-boot-params. This wouldn't require the -m argument and would work even if the repl task is not being called directly.

@bbatsov
Copy link
Member

bbatsov commented May 6, 2016

👍

@arichiardi
Copy link
Contributor

arichiardi commented May 12, 2016

This I think already works ootb, I am constantly doing boot cider dev instead of jacking-in (which sometimes breaks I think exactly for the reason at the top).

I can take care of this, just need some hint on were to put the task and how/where to require it from.
The task would be this right (from boot's wiki)?

deftask cider "CIDER profile"
  []
  (require 'boot.repl)
  (swap! @(resolve 'boot.repl/*default-dependencies*)
         concat '[[org.clojure/tools.nrepl "0.2.12"]
                  [cider/cider-nrepl "0.10.0"]
                  [refactor-nrepl "2.0.0-SNAPSHOT"]])
  (swap! @(resolve 'boot.repl/*default-middleware*)
         concat '[cider.nrepl/cider-middleware
                  refactor-nrepl.middleware/wrap-refactor])
  identity)

@Malabarba
Copy link
Member Author

  1. Almost. It would have to look like this:

    (deftask cider-middleware "CIDER middleware profile"
      []
      (require 'boot.repl)
      (swap! @(resolve 'boot.repl/*default-middleware*)
             conj 'cider.nrepl/cider-middleware)
      identity)
    
    • We don't need to add cider-nrepl as a dependency here, because we already add the dependency on the command-line. (And the task wouldn't be available at all if cider-nrepl weren't already a dep)
    • Instead writing cider.nrepl/cider-middleware, it would be great if we the middlewares were specified as command-line arguments to this task. Then other middlewares (like refactor-nrepl) could inject themselves too.
  2. You can put it in a file called src/cider/tasks.clj.

  3. In order to call this task, we just need to add the string " cider.tasks/cider-middleware " immediately after cider-boot-command-prefix and before cider-boot-repl-task-params inside the function cider-boot-jack-in-dependencies.

@arichiardi
Copy link
Contributor

Great will do!

@arichiardi
Copy link
Contributor

arichiardi commented May 16, 2016

Ok, code-wise I am ready, sorry for my ignorance on this, but is the src folder automatically included in cider? PR is #1751.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants