sources jar has bad resource


  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: Release 1.4, Release 1.5
  • Fix Version/s: Release 1.8
  • Component/s: None
  • Labels:
  • Patch:
  • Approval:


The "sources" jar (at least since Clojure 1.4 and including 1.5 RC) has a bad file in it. The resource clojure/ is literally:


The regular Clojure jar has the correct version string in that resource.

I came across a problem when I was experimenting with the sources jar (as used by IDEs). I naively added the sources jar to my classpath, and Clojure died on start up. The bad clojure/ file was found first, which led to a parse error as the clojure version was being set.

Cause: We configure the maven-source-plugin plugin in our pom.xml to exclude the clojure/ file, and this works for SNAPSHOT builds but NOT for release builds. One difference during release builds is that we are running different goals and profiles, which seems to cause the configuration for the maven-source-plugin to be configured as defined in the oss-parent pom ( instead of our configuration, and so the exclusion is not done.

Solution: If we use the same execution id as used in the oss-parent for the maven-source-plugin configuration, our configuration will override the parent pom configuration and the exclusion will take effect, both in snapshot builds and in release builds. The patch makes this change, just using "attach-sources" as the execution id.

Patch: clj-1161.patch

I was able to reproduce the bad source jar locally by running a command like:

mvn --batch-mode -Dtag=whatever release:prepare -DreleaseVersion=1.8.0-xyz -DdevelopmentVersion=1.8.1-SNAPSHOT

Note that this will generate some local files AND make a local tag and commit! So be careful testing locally if you have commit access (Stu!). You can undo that commit with `git reset HEAD~1` and the tag with `git tag -d whatever`. Before the patch, you should see:

$ jar xf target/clojure-1.8.0-xyz-sources.jar clojure/
$ cat clojure/
version=${version}   # this is the bad stuff

After, you should see that target/clojure-1.8.0-xyz-sources.jar does not contain clojure/ at all:

$ jar tf target/clojure-1.8.0-xyz-sources.jar | grep version
# nothing found



Vote (18)
Watch (2)


  • Created: