Question: any lein plugin experts? eval-in-project should use the classpath of the project passed in, right?

Asked By
Asked At
2017-10-09 14:10:14

Found 15 possible answers.

User Answered At Possible Answer
danielcompton 2017-10-09 18:23:16 Yep, what’s the issue?
djjolicoeur 2017-10-09 19:42:02 @danielcompton I have a witten a plugin using eval-in-project . I am expecting datomic to be present on the classpath of the project, and it is on the project I am testing the plugin on. When I add the plugin to :plugins , _all_ calls to lein fail with a compiler error about not being able to find datomic.api__init.class or datomic/api.clj . datomic is on the classpath, and indeed if I remove the plugin the target app starts up fine with datomic.
danielcompton 2017-10-09 19:43:04 have you required datomic.api in the namespace that your plugin is evaling into? also, if you add datomic to :plugins it will be on Leiningen's classpath, not a long term solution, but good to check exactly where the issue is coming from
djjolicoeur 2017-10-09 19:51:56 datomic.api is required by a namespace that is required in the plugin namespace. The plugin is added to both the projects deps and plugins as it has components that one would want to use from the repl say and others that are best used as a plugin. I find it interesting that it fails on any call to lein though, calls not related to my plugin. that means the forms inside the eval-in-project must be getting evaluated, is that expected? datomic.api only gets pulled in via the require in the setup arg to eval-in-project I will give the second idea about adding datomic to the plugins a shot, I am unfortunately not able to do so at the moment, though
danielcompton 2017-10-09 19:55:07 Try doing it like this I wonder if the require is being run in the lein project, not your one
djjolicoeur 2017-10-09 19:58:40 ha I actually _have_ tried using one form like that. thats actually the last thing I tried before trying to reach out. not sure how to get around that, or why that would be the case for that matter. this project does very much the same things and works fine from the same project. I think you are on to something with it being run from inside the lein project, I just added (require 'datomic.api) directly to the plugin code and that does not fail before that require I had there before, so I think it is failing to compile before it een gets there. not sure why that would be the case, though as datomic is on the classpath
rovanion 2017-10-13 07:40:39 Is there an option in the leiningen conf for me to add an init function for leiningen to run during dev? Wait, wrong channel. Right now it starts the ring server but I want to have it run the init-database fn too.
timgilbert 2017-10-16 19:58:22 Say, out of curiosity is anyone thinking about / writing a way to generate one of the new deps.edn files from a leiningen :dependencies vector?
noisesmith 2017-10-16 20:01:09 @timgilbert at a first glance, basic stuff should be easy - would probably be a fun 2 day lein plugin hack lein export-deps-edn has a nice sound to it
timgilbert 2017-10-16 20:01:28 That's what I was thinking, yeah
ccann 2017-10-19 00:37:16 I’m having trouble writing a plugin. I run my plugin on a project and inside eval-in-project print the classpath and I can see the project there but if I require a namespace from that project it’s a filenotfound exception but if I require ’ instead of ’ it works
noisesmith 2017-10-19 00:40:35 the project itself shouldn't be on classpath though, the src directory (or renamed equivalent) should be
ccann 2017-10-19 01:05:05 hmm, not sure why it’s the top level of the project and not src on the cp
qqq 2017-10-20 23:45:38 <-- I'm converting a project over from boot to lein -- how do I setup a repl to run on port 3000 ?
gonewest818 2017-10-21 06:28:55 @qqq the sample.project.clj documents all the available options ( )
:repl-options {:port 3000})
:profiles {:repl {:plugins [[cider/cider-nrepl "0.16.0-SNAPSHOT"]]}}
[portkey "0.1.0-SNAPSHOT"]]
[org.clojure/clojure "1.9.0-beta2"]
:dependencies [;; clojure core
:url " "}
:license {:name "Eclipse Public License"
:url " "
:description "FIXME: write description"
(defproject foobar "0.1.0-SNAPSHOT"

Related Questions