tools-build

Alex Miller (Clojure team) 2021-09-21T14:02:28.287800Z

tools.build v0.5.1 21da7d4 is now available • update to latest tools.deps.alpha 0.12.1048

🎉 1
Kirill Chernyshov 2021-09-21T15:37:00.290Z

Hi! I’m trying to build an uberjar and getting exception

Execution error (ExceptionInfo) at clojure.tools.build.tasks.uber/explode (uber.clj:172).
Cannot write META-INF/license/LICENSE.tomcat-native.txt from io.netty/netty-tcnative-boringssl-static as parent dir is a file from another lib. One of them must be excluded.
Is it possible to somehow identify which library brought “parent dir”?

dpsutton 2021-09-21T15:43:42.291200Z

we had this issue. If you can run from a repl, the temp dir is still around ( i believe it is deleted on process exit) so you can go see. We found that there is a META-INF/LICENSE file and on case insensitive file systems (osx) this means that LICENSE and license/LICENSE cannot coexist

Kirill Chernyshov 2021-09-21T15:44:53.292Z

aha, thanks! will check

dpsutton 2021-09-21T15:44:55.292200Z

short of that i think you would need to create a basis and look through each jar for which one had the offending file and then report that

Alex Miller (Clojure team) 2021-09-21T15:46:16.292900Z

unfortunately at the point where that message is created, I do not know which lib explode put it on disk originally

Alex Miller (Clojure team) 2021-09-21T15:46:38.293500Z

but the right solution here is probably to add a conflict handler - there is one for licenses, but this is outside its regex

Alex Miller (Clojure team) 2021-09-21T15:47:24.293800Z

api doc is at https://clojure.github.io/tools.build/clojure.tools.build.api.html#var-uber

Alex Miller (Clojure team) 2021-09-21T15:47:44.294200Z

at the bottom you can see the default conflict handlers

{"^data_readers.clj[cs]?$" :data_readers
   "^META-INF/services/" :append
   "(?i)^(META-INF/)?(COPYRIGHT|NOTICE|LICENSE)(\.(txt|md))?$" :append-dedupe
   :default :ignore}

Kirill Chernyshov 2021-09-21T15:48:53.296200Z

thanks btw there is a small mistake in that doc - :data-reader instead of :data_readers and “(?i)^(META-INF/)?(COPYRIGHT|NOTICE|LICENSE)(\.(txt|md))?$” should be “(?i)^(META-INF/)?(COPYRIGHT|NOTICE|LICENSE)(\\.(txt|md))?$”

Alex Miller (Clojure team) 2021-09-21T16:02:09.300700Z

fixed, the data-readers. the other is right (this is a string, not a regex so you need to escape the \, which will when turned into a regex will escape the .)

Kirill Chernyshov 2021-09-21T16:07:10.300900Z

but clojure complains about Unsupported escape character: \. if I copy that map to the build file

Alex Miller (Clojure team) 2021-09-21T16:08:12.301200Z

oh, ha - it's "right" in the docstring, but being applied there so it shows up wrong in the docs :)

Alex Miller (Clojure team) 2021-09-21T16:08:39.301400Z

I need one additional level of escaping in the docstring :)

Alex Miller (Clojure team) 2021-09-21T16:10:17.301600Z

fixed

Kirill Chernyshov 2021-09-21T17:05:14.301900Z

Thanks!

Alex Miller (Clojure team) 2021-09-21T15:48:57.296400Z

you can supply :conflict-handlers {"(?i)^META-INF/license/LICENSE.tomcat-native.txt" :append-dedupe}

Kirill Chernyshov 2021-09-21T15:50:50.297600Z

same exception ( looks like this is the problem of MacOS filesystem

dpsutton 2021-09-21T15:52:13.298200Z

it looks like conflict handlers only get triggered when the same file already exists? if so i don't think it can help in this situation right?

Kirill Chernyshov 2021-09-21T15:52:29.298500Z

right

Alex Miller (Clojure team) 2021-09-21T15:52:31.298600Z

oh right, sorry, I'm crossing things

Alex Miller (Clojure team) 2021-09-21T15:52:42.298900Z

this is the file/directory conflict

Alex Miller (Clojure team) 2021-09-21T15:53:13.299300Z

the problem is there is a file META-INF/license already on disk

Alex Miller (Clojure team) 2021-09-21T15:53:36.299600Z

so it can't make the directory META-INF/LICENSE/

Alex Miller (Clojure team) 2021-09-21T15:54:21.300300Z

so the only solution atm is to exclude one or the other file

Kirill Chernyshov 2021-09-21T15:56:29.300600Z

yeah, it works after adding to :exclude list

seancorfield 2021-09-21T17:15:29.303200Z

@delaguardo We ran into that and it was coming from io.gprc/grpc-netty-shaded (I think) and we excluded that and added a dep on io.gprc/gprc-okhttp which is an alternate impl and that worked fine (and produced a smaller uberjar).

seancorfield 2021-09-21T17:16:06.303700Z

Yeah, here it is, from the Google Cloud Vision deps:

com.google.cloud/google-cloud-vision {:mvn/version "1.103.7"
                                        :exclusions [io.grpc/grpc-netty-shaded]}
  io.grpc/grpc-okhttp {:mvn/version "1.39.0"}