Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAR file entry order should be consistent with the Ant Task #23

Open
jgustie opened this issue Oct 20, 2015 · 0 comments
Open

JAR file entry order should be consistent with the Ant Task #23

jgustie opened this issue Oct 20, 2015 · 0 comments

Comments

@jgustie
Copy link

jgustie commented Oct 20, 2015

I was having a hard time getting my project to run correctly when built with this plugin, in particular I could not get log4j initialized correctly. I noticed the following logging statement coming from OneJar:

[JarClassLoader] INFO:  log4j.properties in main/main.jar is hidden by lib/utils.jar (with different bytes)

It turned out that utils.jar had a log4j.properties file and I had just assumed that OneJar would prefer the one from main.jar. Reading the OneJar documentation closely, I noticed the section on resource loading includes the following caveat:

Note: this assumes that the Ant task is used to construct the One-Jar. Otherwise, embedded Jar resources are loaded in the order they appear in the "jar -tvf" listing.

Sure enough, running "jar tf" on the JAR produced by this plugin was listing all of the "lib" contents ahead of the "main/main.jar" entry.

Looking at the code I suspect this is the fault of a lexicographical sort on contents of staging directory. The OneJar Ant Task from the official project does not include in the main.jar in the staging area, instead it explicitly adds it as the first entry to the JAR file (running "jar tf" on a JAR from the Ant task confirms this). Perhaps if it would be possible to make a similar change here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant