This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-03
Channels
- # aws (5)
- # beginners (67)
- # boot (30)
- # cider (55)
- # clara (7)
- # cljs-dev (6)
- # cljsjs (6)
- # cljsrn (1)
- # clojure (136)
- # clojure-brasil (2)
- # clojure-dusseldorf (14)
- # clojure-finland (9)
- # clojure-italy (49)
- # clojure-nl (1)
- # clojure-romania (6)
- # clojure-russia (4)
- # clojure-uk (16)
- # clojurescript (136)
- # core-async (1)
- # cursive (21)
- # datomic (64)
- # fulcro (26)
- # hoplon (25)
- # jobs-discuss (53)
- # keechma (3)
- # leiningen (6)
- # luminus (11)
- # lumo (2)
- # off-topic (351)
- # om (1)
- # onyx (11)
- # parinfer (32)
- # portkey (9)
- # re-frame (45)
- # reagent (38)
- # shadow-cljs (60)
- # specter (9)
- # vim (8)
- # yada (22)
Can anyone point me towards examples of including/compiling .java files in a boot build?
(! 998)-> boot javac -h
Compile java sources.
Options:
-h, --help Print this help info.
-o, --options OPTIONS Conj OPTIONS onto list of options passed to the java compiler.
I assume it just compiles any .java
files it finds in the :source-paths
or :resource-paths
(but I haven't checked the source code).Yup, looks like it compiles all .java
"input files" https://github.com/boot-clj/boot/blob/49ea7d6207e694f98375f57776846732e3c91908/boot/core/src/boot/task/built_in.clj#L811
@seancorfield cheers. seems like compilation is (maybe) working. still can't get the compiled files to get picked up properly in my clojure code 😕
Hmm, do you have an example up on GitHub I can take a look at?
Not yet. One of the things I'm currently frustrated with in Clojure is my inability to really extract stuff out quickly. Feels like I'm Doing It Wrongâ„¢.
'k... FWIW, I just created a new app
boot -d boot/new new -t app -n jj
then added src/jj/Stuff.java
as package jj;
public class Stuff {
public String greet( String s ) {
return "Hello " + s + "!";
}
}
and edited src/jj/core.clj
to import and call it: (ns jj.core
(:import [jj Stuff])
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(let [s (Stuff.)]
(println (.greet s "Sean")))
(println "Hello, World!"))
and then boot javac build
to produce a JAR and (! 878)-> java -jar target/jj-0.1.0-SNAPSHOT-standalone.jar
Hello Sean!
Hello, World!
I realized there's a bug in the generated run
task in the template -- so you can't do build javac run
unless you update the run
task
(deftask run
"Run the project."
[a args ARG [str] "the arguments for the application."]
(with-pass-thru fs
(require '[jj.core :as app])
(apply (resolve 'app/-main) args)))
(it needs the with-pass-thru
wrapper)
That works as expected, so there's something else going on in my larger project. Thanks for the remote support. Having someone out there on the other end makes a difference!
@grzm Happy to help, wherever I can!
Both boot test
and boot alt-test
pass for me in that project.
I notice that if you edit the Java source, the tests say "No tests found", but if you edit the Clojure tests, it finds them.
I didn't realize you were also using boot-tools-deps
... yes, with alt-test
I haven't -- yet -- tackled the somewhat daunting task of converting our build at work over to the new deps.edn
format. We have all our dependencies external, but in a simplified format at the moment.
It's definitely something I want to do at some point since it would allow us to simplify our build and our tooling stack.
We have a whole bunch of subprojects in a mono-repo and, right now, we have a complex Boot task that automatically figures out what each one depends on (and enforces certain rules about which cannot depend on what). But I'd like to simplify that and make it all explicit (esp. since we've now decided to take down the walls between some of the projects). So I think the local deps would be perfect for this.
oh, if you type Enter, you can force alt-test to run all of the tests. That seems to work for me when changing the java file. EDIT TO ADD: Nope. While it looks like it recompiles the class, it doesn't reload it.
If you do boot watch test
it all works as expected -- editing either source or tests pick up the changes.
I've seen a few other people report strange behavior trying to use alt-test
with boot-tools-deps
@grzm
I dunno if it's interaction between the two. alt-test
does reloading magic, so it wouldn't surprise me if it misses Java classes and only pays attention to Clojure namespace.
You might find if you move the (watch)
before the (deps ..)
for the alt-test
task, it might work too...
Nope.
So, yeah, it might well be some peculiarity of alt-test
...