<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged uberjar</title>
<link>https://ask.clojure.org/index.php/tag/uberjar</link>
<description></description>
<item>
<title>create-basis uses the wrong local maven repository</title>
<link>https://ask.clojure.org/index.php/12232/create-basis-uses-the-wrong-local-maven-repository</link>
<description>&lt;p&gt;I am attempting to build a Clojure project with numerous dependencies and contain everything into a single folder. The reason for doing this is because I will eventually build this software in an environment where I am not permitted to modify the home folder.&lt;/p&gt;
&lt;p&gt;The following command is being used&lt;br&gt;
&lt;code&gt;GITLIBS=/var/build/software/.gitlibs clojure -Srepro -Sdeps '{:mvn/local-repo &quot;/var/build/software/.m2/repository&quot;}' -T:build uber-aot&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;tools.deps is able to download all dependencies into the specified local repository. Once it's time for tools.build to run, I seem to get an error in the middle of a call to &lt;code&gt;b/create-basis&lt;/code&gt;. Here is what the error looks like.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Execution error (FileNotFoundException) at java.io.RandomAccessFile/open0 (RandomAccessFile.java:-2).
/home/user/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.pom.part.lock (No such file or directory)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Is there any way to pass in the local Maven repository to tools.build? Preferably in the command line.&lt;/p&gt;
</description>
<category>Clojure CLI</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12232/create-basis-uses-the-wrong-local-maven-repository</guid>
<pubDate>Sat, 24 Sep 2022 08:29:08 +0000</pubDate>
</item>
<item>
<title>Ability to customise java-cmd in tools.build</title>
<link>https://ask.clojure.org/index.php/12134/ability-to-customise-java-cmd-in-tools-build</link>
<description>&lt;p&gt;Moving the original &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C02B5GHQWP4/p1661625386101119&quot;&gt;question&lt;/a&gt; from Clojurians Slack:&lt;/p&gt;
&lt;p&gt;When moving one of my projects to JDK 19 I was pointing clojure to the jdk using the &lt;strong&gt;JAVA_CMD&lt;/strong&gt; env var. Everything was fine til I hit the uber jar step in the CI, where it simply refused to recognise the jdk 19 functions.&lt;/p&gt;
&lt;p&gt;Took me a while and including reading the tools.build source to realise why it wasn't propagating the &lt;strong&gt;JAVA_CMD&lt;/strong&gt; var and turns out I had to read env and send the &lt;strong&gt;:java_cmd&lt;/strong&gt; in the &lt;strong&gt;b/compile-clj&lt;/strong&gt; call.&lt;/p&gt;
&lt;p&gt;I can see why the behaviour is like this, but would &lt;strong&gt;:java_cmd&lt;/strong&gt; defaulting to the value of &lt;strong&gt;JAVA_CMD&lt;/strong&gt; something that could be considered? Feels a bit more intuitive for me, as mostly the invocations of tools.build fns would be from the shell.&lt;/p&gt;
</description>
<category>tools.build</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12134/ability-to-customise-java-cmd-in-tools-build</guid>
<pubDate>Sat, 27 Aug 2022 20:54:32 +0000</pubDate>
</item>
<item>
<title>Files in deps :local/root :git/url will directly copy into uberjar without go through conflict-handlers</title>
<link>https://ask.clojure.org/index.php/11788/local-directly-uberjar-without-through-conflict-handlers</link>
<description>&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/tools.build/blob/1309f935b098123eb807c972a053eeab77f6f4cd/src/main/clojure/clojure/tools/build/tasks/uber.clj#L172&quot;&gt;https://github.com/clojure/tools.build/blob/1309f935b098123eb807c972a053eeab77f6f4cd/src/main/clojure/clojure/tools/build/tasks/uber.clj#L172&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The handling between jar and lib folders like git deps or local root are completely different. In my case, I have some config files in edn format (duct's duct_hierarchy.edn) exists in both jar deps and git deps. My additional conflict handler is never receiving the edn file that exists in git deps.&lt;/p&gt;
&lt;p&gt;Is it the expected behaviour? I can imagine that even &lt;strong&gt;LICENSE&lt;/strong&gt; or &lt;strong&gt;data_readers.clj&lt;/strong&gt; would suffer the same issue. e.g. being overrided by files in git deps.&lt;/p&gt;
</description>
<category>tools.build</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11788/local-directly-uberjar-without-through-conflict-handlers</guid>
<pubDate>Fri, 22 Apr 2022 10:58:50 +0000</pubDate>
</item>
<item>
<title>Is it possible to build an uberwar using deps.edn using tools.build or other tool?</title>
<link>https://ask.clojure.org/index.php/11341/possible-build-uberwar-using-deps-using-tools-build-other-tool</link>
<description>&lt;p&gt;We have a small Clojure &amp;amp; ClojureScript web app running in Tomcat. The project managed to end up with a deps.edn for use with Shadow-cljs &amp;amp; lein for the backend to essentially build an uberwar. Is there a way to build an uberwar with tools-build or in some other way using deps.edn?&lt;/p&gt;
&lt;p&gt;Thanks for any pointers&lt;/p&gt;
&lt;p&gt;Cheers&lt;br&gt;
Daniel Sunnerek&lt;/p&gt;
</description>
<category>tools.build</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11341/possible-build-uberwar-using-deps-using-tools-build-other-tool</guid>
<pubDate>Thu, 02 Dec 2021 13:22:01 +0000</pubDate>
</item>
<item>
<title>tools.build uber's default conflict handlers don't append to META-INF/services properly</title>
<link>https://ask.clojure.org/index.php/11316/tools-default-conflict-handlers-append-services-properly</link>
<description>&lt;p&gt;Our project has some dependencies that register parsers for various file formats via the java services framework.&lt;/p&gt;
&lt;p&gt;We’re using &lt;code&gt;b/uber&lt;/code&gt; and are finding some &lt;code&gt;META-INF/services/&lt;/code&gt; definitions are not correctly being appended.  &lt;/p&gt;
&lt;p&gt;I’ve chased this down to the regex in the default-handlers being &lt;code&gt;^META-INF/services/&lt;/code&gt; instead of something more like &lt;code&gt;^META-INF/services/.*&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The current regex would match under &lt;code&gt;re-find&lt;/code&gt;, but not under &lt;code&gt;re-matches&lt;/code&gt; which the implementation uses.&lt;/p&gt;
</description>
<category>tools.build</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11316/tools-default-conflict-handlers-append-services-properly</guid>
<pubDate>Fri, 26 Nov 2021 17:29:12 +0000</pubDate>
</item>
<item>
<title>How to control the transient deps that get compiled/assembled into an uberjar?</title>
<link>https://ask.clojure.org/index.php/10905/control-transient-deps-that-compiled-assembled-into-uberjar</link>
<description>&lt;p&gt;I am having trouble understanding how to control the contents of an uberjar using &lt;code&gt;tools.build&lt;/code&gt;. In this scenario, the runtime environment (a Spark cluster) provides some deps and thus those deps should not be in the uberjar. Let's say I have 2 classpaths (represented as aliases):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;:compile&lt;/code&gt; The classpath with all deps/classes that are required for compilation. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;:uber&lt;/code&gt; The classpath with only the deps/classes that should be in the final jar. &lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In theory, if you take the &lt;code&gt;:compile&lt;/code&gt; classpath and subtract the &lt;code&gt;:uber&lt;/code&gt; classpath, we should get the set of classes that are provided by the runtime environment. &lt;/p&gt;
&lt;p&gt;Consider the following simplified dependency graph:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://mermaid.ink/img/eyJjb2RlIjoiZ3JhcGggTFJcbiAgICBwcm9qW215LnByb2plY3QvYXBwXSAtLT4gc3FsXG4gICAgcHJvaltteS5wcm9qZWN0L2FwcF0gLS0-IGNvcmVcbiAgICBwcm9qW215LnByb2plY3QvYXBwXSAtLT4gc2NhbGFcbiAgICBwcm9qW215LnByb2plY3QvYXBwXSAtLT4gb3RoZXJbc29tZS5vdGhlci9kZXBdXG4gICAgb3RoZXIgLS0-IHRyYW5zW3NvbWUudHJhbnNpZW50L2RlcF1cbiAgICBzcWxbb3JnLmFwYWNoZS5zcGFyay9zcWxdIC0tPiBjb3JlXG4gICAgY29yZVtvcmcuYXBhY2hlLnNwYXJrL2NvcmVdIC0tPiBhcGFjaGVbb3JnLmFwYWNoZS5jb21tb25zLypdXG4gICAgY29yZVtvcmcuYXBhY2hlLnNwYXJrL2NvcmVdIC0tPiBzY2FsYVtvcmcuc2NhbGEtbGFuZy9zY2FsYS1saWJyYXJ5XVxuICAgXG4gICAgc3R5bGUgc3FsIGZpbGw6I0ZGRlxuICAgIHN0eWxlIGNvcmUgZmlsbDojRkZGXG4gICAgc3R5bGUgc2NhbGEgZmlsbDojRkZGXG4gICAgc3R5bGUgYXBhY2hlIGZpbGw6I0ZGRiIsIm1lcm1haWQiOnsidGhlbWUiOiJkZWZhdWx0In0sInVwZGF0ZUVkaXRvciI6ZmFsc2UsImF1dG9TeW5jIjp0cnVlLCJ1cGRhdGVEaWFncmFtIjpmYWxzZX0&quot; alt=&quot;dep graph&quot;&gt;&lt;/p&gt;
&lt;p&gt;We only need the blue deps to be in the jar. The white &quot;provided&quot; deps need to be used during compilation but should not be in the final uberjar. &lt;/p&gt;
&lt;p&gt;I looked into using the &lt;code&gt;:filter-nses&lt;/code&gt; option of &lt;code&gt;compile-clj&lt;/code&gt; but it creates problems with transient deps.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If we filter to only &lt;code&gt;my.project&lt;/code&gt; we will lose the important deps of &lt;code&gt;some.other/dep&lt;/code&gt; and &lt;code&gt;some.transient/dep&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If we filter to exclude &lt;code&gt;org.apache&lt;/code&gt; (not possible with &lt;code&gt;:filter-nses&lt;/code&gt;, but in theory it could be done) we would still have &lt;code&gt;org.scala-lang/scala-library&lt;/code&gt; hanging around.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I also experimented using different calls to &lt;code&gt;create-basis&lt;/code&gt; during compile and jar building. I'm not sure if that makes any sense.&lt;/p&gt;
&lt;p&gt;Is it possible to leverage the dependency graph to control either 1) what gets compiled or 2) which classes get put into an uberjar? Any advice would be much appreciated.&lt;/p&gt;
</description>
<category>tools.build</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10905/control-transient-deps-that-compiled-assembled-into-uberjar</guid>
<pubDate>Thu, 05 Aug 2021 16:36:31 +0000</pubDate>
</item>
<item>
<title>Using static files in project</title>
<link>https://ask.clojure.org/index.php/10516/using-static-files-in-project</link>
<description>&lt;p&gt;Probably a very noob question, sorry about that. I have a monorepo structured like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;api/ 
 |-deps.edn
 |-src/
   |-api/
     |-core.clj
     |-resource_1.csv
library/
 |-deps.edn
 |-src/
   |-library/
     |-core.clj
     |-resource_2.csv
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;deps.edn of the api uses library as local dependency. Both of them use static information from respective csv files.&lt;/p&gt;
&lt;p&gt;My question is how do I correctly include the static files when compiling the api uberjar, and how do I correctly use the static files within the code?&lt;/p&gt;
&lt;p&gt;The api does not have any endpoints where it's serving the static files. They're used inside the code for caclulations.&lt;/p&gt;
</description>
<category>IO</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10516/using-static-files-in-project</guid>
<pubDate>Thu, 22 Apr 2021 18:13:10 +0000</pubDate>
</item>
<item>
<title>Fails to load gen-classed class with pf4j from uberjar</title>
<link>https://ask.clojure.org/index.php/10093/fails-to-load-gen-classed-class-with-pf4j-from-uberjar</link>
<description>&lt;p&gt;The problem here might be more related to the pf4j default classloader but still:&lt;/p&gt;
&lt;p&gt;I have a clojure plugin generating a class &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(gen-class
 :name myplugin.SomeExtension
 :implements [plugin.SomeExtensionPoint]
 :prefix &quot;-&quot;
 :impl-ns my-plugin.some-extension)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The plugin jar  is loaded in my clojure application using pf4j. When it is compiled with &lt;code&gt;lein jar&lt;/code&gt; the class loads (but then I naturally have to put any plugin dependencies in the apps &lt;code&gt;project.clj&lt;/code&gt;). When compiled with &lt;code&gt;lein uberjar&lt;/code&gt; it fails with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; Execution error (IllegalStateException) at myplugin.SomeExtension/&amp;lt;clinit&amp;gt; (REPL:-1).
; Attempting to call unbound fn: #'clojure.core/refer
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;with top of call stack&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;jdk.internal.reflect.NativeConstructorAccessorImpl/newInstance0 (NativeConstructorAccessorImpl.java:-2)
jdk.internal.reflect.NativeConstructorAccessorImpl/newInstance (NativeConstructorAccessorImpl.java:62)
jdk.internal.reflect.DelegatingConstructorAccessorImpl/newInstance (DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor/newInstance (Constructor.java:490)
java.lang.Class/newInstance (Class.java:584)
org.pf4j.DefaultExtensionFactory/create (DefaultExtensionFactory.java:38)
org.pf4j.ExtensionWrapper/getExtension (ExtensionWrapper.java:37)
org.pf4j.AbstractPluginManager/getExtensions (AbstractPluginManager.java:971)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I've struggled a bit but I am unsure about exactly what happens here and how to solve it?&lt;br&gt;
Any ideas are most welcome!&lt;/p&gt;
&lt;p&gt;(and the uberjar profile uses &lt;code&gt;{:aot :all :omit-source true}&lt;/code&gt;)&lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10093/fails-to-load-gen-classed-class-with-pf4j-from-uberjar</guid>
<pubDate>Tue, 26 Jan 2021 16:23:57 +0000</pubDate>
</item>
</channel>
</rss>