Fork me on GitHub
#tools-deps
<
2020-06-11
>
nha19:06:02

I am looking for something like a maven api that I can call from a Clojure app to make a .jar from a java file + it’s main class name. I’ve never used maven directly (at least not in anger). Any opinions here? For context: I am making a .jar and uploading it to a lambda-like service. Not about tool deps so I hope this is OK - seems like the place where I am most likely to get answers 🙂 Please reply in the thread

nha19:06:18

Please reply here to keep the channel tidy 🙂

dominicm19:06:33

@U0ALP2929 What service are you using? I created an AWS lambda-specific output for pack and would be interested in targetting others.

nha19:06:03

So hence lambda-like, it’s not exactly the same. However they accept a

--jar target/my-jar-with-dependencies.jar \
  --classname org.example.functions.WordCountFunction \

dominicm19:06:04

OK, looks like you need an uberjar of some kind in that case. I would recommend the library @U04V70XH6 maintains for that.

dominicm19:06:47

There's downsides to uberjars (which is why pack doesn't produce them), I'm curious to know if they accept anything else, so I'm reading the docs now :)

dominicm19:06:00

That's the one :)

simple_smile 4
dominicm19:06:21

Doesn't look positive for alternative forms. Unfortunate. Depstar is what I'd recommend :)

nha19:06:56

depstar looks like it is supposed to be used from the CLI, and not sure it supports .java files? I am looking for something to embed. I could always shell it / reach into the namespaces though

dominicm19:06:34

Oh, sorry, I thought you wanted to make a jar for clojure

dominicm19:06:43

Right, you don't need much at all

dominicm19:06:58

javac MyFile.java then zip jar.jar MyFile.java

dominicm19:06:01

that's it, you're done!

dominicm19:06:11

there might be an official java tool for making a jar, but zip works OK

seancorfield19:06:13

@U0ALP2929 To build uberjars with depstar, you should be able to depend on the library and call hf.depstar.uberjar/run with the appropriate options -- see how the -main function sets those up. It assumes there's a pom.xml file available because it uses the presence of that to trigger some of the AOT and manifest generation stuff. It assumes, at a minimum, you've run clojure -Spom in a project, but you could probably generate a stub pom.xml as a temp file and pass that in.

seancorfield19:06:15

And depstar works from the classpath -- so it will build a JAR from whatever is on your classpath which is very likely not what you're looking for 🙂

seancorfield19:06:55

jar is the "official Java tool for making a jar" but it's basically just zip 🙂

nha19:06:10

Ahah I see 🙂 not what I am looking for indeed. Shelling to javac or even mvn looks like it could be the way then

nha19:06:40

I found this http://maven.apache.org/ref/3.1.0/maven-embedder/index.html but I fear it may be a can of worms 😄