Fork me on GitHub
#tools-deps
<
2020-03-27
>
dorab03:03:02

Using Sean Corfield's fork of depstar, and running the command clj -A:uberjar x.jar, I get

Building uber jar: x.jar
{:warning "clashing jar item", :path "META-INF/services/com.fasterxml.jackson.core.JsonFactory", :strategy :concat-lines}
{:warning "clashing jar item", :path "META-INF/services/com.fasterxml.jackson.core.JsonFactory", :strategy :concat-lines}
I know it is just a warning, but what do I do to fix it? My deps.edn is
{:paths ["src"]                         ;until TDEPS-52 is fixed
 :aliases
 {:test
  {:extra-paths ["test"]
   :extra-deps {org.clojure/test.check {:mvn/version "RELEASE"}}}
  :runner
  {:extra-deps
   {com.cognitect/test-runner
    {:git/url ""
     :sha "76568540e7f40268ad2b646110f237a60295fa3c"}}
   :main-opts ["-m" "cognitect.test-runner" "-d" "test"]}}
 :deps
 {
  cheshire {:mvn/version "5.10.0"}
  http-kit {:mvn/version "2.3.0"}
  org.clojure/clojure {:mvn/version "1.10.1"}
  }
 }
If this is not the appropriate channel, please redirect me. Thanks.

seancorfield03:03:17

You don't do anything to fix it. It's just warning you, so you know that the same file is being copied into your JAR multiple times (and it is handling it by concatenating the files). Jackson is a horribly problematic library -- it is the cause of most of the version conflicts we see people run into these days but unfortunately it's also fairly ubiquitous so...

seancorfield03:03:07

I'm a bit surprised you're seeing the message twice -- that implies three copies of the file are being found on the classpaths...

seancorfield03:03:53

The 1.0.x version of depstar (currently on master) will have a -S / --suppress-clash option to hide that warning message(!) but you can currently use the -v / --verbose option to learn more about what it is bringing in @dorab

seancorfield04:03:23

OK, I've repro'd based on your deps.edn and it looks like each of the three Jackson libraries being pulled in by Cheshire all contain that same file.

seancorfield04:03:00

Yup, seems like each of the Jackson JAR files (core, databind-cbor, and databind-smile) all contain that file and it has a class name in it that matches one in the library it comes from. I'm fairly certain this is harmless and "expected behavior". Perhaps @ghadi can confirm when he is next around, since he's the original author of the first version of depstar...?

seancorfield04:03:18

(this seems like another reason to try using clojure.data.json instead of cheshire 🙂 )

dorab04:03:11

Thanks @seancorfield. I will try to use clojure.data.json instead.

dorab04:03:08

If the same file is being requested multiple times, could depstar just include it once? Sorry if I'm being naive.

seancorfield04:03:30

No, the same named file is included in three different libraries.

seancorfield04:03:55

As I said above, Cheshire pulls in Jackson, and that means you get its core, cbor, and smile libs (dataformat, not databind, my bad -- rest of it still applies). Each of those three libs includes the same file. depstar concatenates the lines in each file to create a single file in the resulting JAR.

dorab04:03:56

Gotit. Thanks.

seancorfield04:03:33

Interestingly, dataformat-smile and dataformat-cbor are both deprecated and archived. Ah, looks like dataformat-binary is the replacement for both of those now. Sheesh, that is one weird, troublesome library...

fabrao15:03:04

Hello all, how to convert this lein uberjar

:main ^:skip-aot app.core
  :uberjar-name "project.jar"
  :profiles {:uberjar {:aot :all}}

fabrao15:03:21

to deps.end alias?

seancorfield16:03:28

It has an example in the readme

# generate pom.xml (or create it manually)
clojure -Spom
# build the uberjar with AOT compilation
clojure -A:depstar -m hf.depstar.uberjar MyProject.jar -C -m project.core
# Main-Class: project.core
java -jar MyProject.jar

seancorfield16:03:52

(use project.jar instead of MyProject.jar and app.core instead of project.core)

seancorfield16:03:23

You'll need to edit the pom.xml generated by clojure -Spom to add more stuff. Take a look at a pom.xml file generated by clj-new (if you created your project with a recent version of clj-new and the app template, then the pom.xml file will probably be almost 100% of what you would need for depstar and deployment to Clojars anyway).

fabrao17:03:34

@seancorfield I tried -A:uberjar from your dot-clojure but I didn´t know about pom.xml

fabrao17:03:01

so I creat project.clj to generate jar