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

OneJar broken for multi-project builds #4

Closed
benmccann opened this issue Jan 26, 2011 · 9 comments
Closed

OneJar broken for multi-project builds #4

benmccann opened this issue Jan 26, 2011 · 9 comments

Comments

@benmccann
Copy link

From discussion on:
http://jira.codehaus.org/browse/GRADLE-566?focusedCommentId=253025#action_253025

$ gradle oneJar
:unpackOneJar SKIPPED
:typedefOneJar
:java/com/benmccann/test/db:compileJava UP-TO-DATE
:java/com/benmccann/test/db:processResources UP-TO-DATE
:java/com/benmccann/test/db:classes UP-TO-DATE
:java/com/benmccann/test/db:jar UP-TO-DATE
:java/com/benmccann/test/backend:compileJava UP-TO-DATE
:java/com/benmccann/test/backend:processResources UP-TO-DATE
:java/com/benmccann/test/backend:classes UP-TO-DATE
:java/com/benmccann/test/backend:jar UP-TO-DATE
:java/com/benmccann/test/backend:oneJar

FAILURE: Build failed with an exception.

Where:
Build file '/home/bmccann/workspace/test/java/com/benmccann/test/backend/build.gradle'
What went wrong:
Execution failed for task ':java/com/benmccann/test/backend:oneJar'.
Cause: Problem: failed to create task or type one-jar
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.

@RobertFischer
Copy link
Owner

Interesting...looks like "ant" is localized per-project. What do you think is a better solution—typedef'ing on each project where you want to use oneJar, or using the root project's "ant"?

@benmccann
Copy link
Author

I'm afraid I don't really understand the question since I'm brand new to gradle and don't understand it's internals very well yet. What are the end-user visible implications of the two options?

@RobertFischer
Copy link
Owner

If people mess with their ant implementation, it wouldn't be reflected.

I just answered my own question—going to have to typedef per project.

I'll release a fix tomorrow.

@RobertFischer
Copy link
Owner

Try 0.6.8 and let me know how that goes.

@benmccann
Copy link
Author

It didn't bomb out this time :o)
There were a few things I thought were a bit funky with the generated jar:

  • It has the the oneJar classes in it which is strange.
  • It didn't unpack any of the jars within it (I assume it's supposed to do this since that's how Maven's jar-with-dependencies work)
  • It double included my own code. I have db project which is a database library used by multiple other projects to talk to the same database. Then I have other projects which depend on db such as the frontend project I posted below as an example. You'll see that it included db-1.0.jar and db-oneJar.jar in the frontend-oneJar.jar

$ jar -tf frontend-oneJar.jar
.version
OneJar.class
com/simontuffs/onejar/Boot$1.class
com/simontuffs/onejar/Boot$2.class
com/simontuffs/onejar/Boot$3.class
com/simontuffs/onejar/Boot.class
com/simontuffs/onejar/Handler$1.class
com/simontuffs/onejar/Handler.class
com/simontuffs/onejar/IProperties.class
com/simontuffs/onejar/JarClassLoader$1.class
com/simontuffs/onejar/JarClassLoader$2.class
com/simontuffs/onejar/JarClassLoader$ByteCode.class
com/simontuffs/onejar/JarClassLoader$FileURLFactory$1.class
com/simontuffs/onejar/JarClassLoader$FileURLFactory.class
com/simontuffs/onejar/JarClassLoader$IURLFactory.class
com/simontuffs/onejar/JarClassLoader$OneJarURLFactory.class
com/simontuffs/onejar/JarClassLoader.class
com/simontuffs/onejar/OneJarFile$1.class
com/simontuffs/onejar/OneJarFile$2.class
com/simontuffs/onejar/OneJarFile.class
com/simontuffs/onejar/OneJarURLConnection.class
doc/one-jar-license.txt
META-INF/
META-INF/MANIFEST.MF
struts.xml
lib/
lib/db-1.0.jar
lib/db-oneJar.jar
lib/guice-3.0-rc2.jar
lib/javax.inject-1.jar
lib/aopalliance-1.0.jar
lib/cglib-2.2.1-v20090111.jar
lib/asm-3.1.jar
lib/hibernate-core-3.6.0.Final.jar
lib/antlr-2.7.6.jar
lib/commons-collections-3.1.jar
lib/dom4j-1.6.1.jar
lib/hibernate-commons-annotations-3.2.0.Final.jar
lib/slf4j-api-1.6.1.jar
lib/hibernate-jpa-2.0-api-1.0.0.Final.jar
lib/jta-1.1.jar
lib/hibernate-entitymanager-3.6.0.Final.jar
lib/cglib-2.2.jar
lib/javassist-3.12.0.GA.jar
lib/slf4j-log4j12-1.6.1.jar
lib/log4j-1.2.16.jar
lib/guice-struts2-3.0-rc2.jar
lib/guice-servlet-3.0-rc2.jar
lib/xercesImpl-2.9.1.jar
lib/xml-apis-1.3.04.jar
lib/struts2-core-2.2.1.jar
lib/xwork-core-2.2.1.jar
lib/ognl-3.0.jar
lib/freemarker-2.3.16.jar
lib/commons-fileupload-1.2.1.jar
lib/commons-io-1.3.2.jar
lib/jasper-6.0.29.jar
lib/servlet-api-6.0.29.jar
lib/juli-6.0.29.jar
lib/jsp-api-6.0.29.jar
lib/el-api-6.0.29.jar
lib/catalina-6.0.29.jar
lib/annotations-api-6.0.29.jar
lib/jasper-jdt-6.0.29.jar
lib/jasper-el-6.0.29.jar
lib/jetty-webapp-8.0.0.M2.jar
lib/servlet-api-3.0.20100224.jar
main/
main/frontend-1.0.jar

@RobertFischer
Copy link
Owner

That's how oneJar works—it doesn't unpack the jars, but crams them inside with its own Main class and does some classpath funkiness to wire things up properly. This prevents issues from arising with resources and the like.

Now, the fact that I'm including your other oneJar jars is bad. It won't wreck your program, but it does waste some space. I need to put a filter in to take out oneJar artifacts from builds...

@RobertFischer
Copy link
Owner

Try 0.6.9-SNAPSHOT. Let me know how that goes.

@benmccann
Copy link
Author

Thanks Robert! It seemed mostly to work, but it bombs out when I try to run the jar. It seems to be because I'm using Guice and because of the classpath funkiness that oneJar does. It looks like you have to include an extra oneJar library in order to use Guice:
http://one-jar.sourceforge.net/index.php?page=frameworks&file=guice

Here's the error I get:
Jan 28, 2011 7:33:07 PM com.google.inject.internal.util.$FinalizableReferenceQueue$DecoupledLoader loadFinalizer
WARNING: Could not load Finalizer in its own class loader. Loading Finalizer in the current class loader instead. As a result, you will not be able to garbage collect this class loader. To support reclaiming this class loader, either resolve the underlying issue, or move Google Collections to your system class path.
java.lang.ClassNotFoundException: com.google.inject.internal.util.$Finalizer
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)

@RobertFischer
Copy link
Owner

I'm closing this issue. Opened this one: https://github.com/RobertFischer/gradle-plugins/issues/issue/5

This issue was closed.
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

2 participants