Re: Building standalone jars
Wayne Fay wrote: I guess my general question is: How do you build standalone executable jars that don't depend on other jars moving along with them? Shade plugin. It is also very easy to do with the uberjar plugin http://maven.apache.org/maven-1.x/plugins/uberjar/ - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Building standalone jars
On Tue, Mar 23, 2010 at 04:38:32AM +, Ron Wheeler wrote: Everyone should be used to using Classes that are grouped into libraries. yes -- that's what I require adding jars to my classpath for. Jan T. Kim wrote: Dear All, I need to build a standalone executable jar and have the following difficulties: * the app needs a bunch of classes from another module break the other module into a jar that contains the sharable classes and an application that depends on that jar * the app needs classes provided by non-Maven jars Get Nexus and load the non-Maven, non-yours jars into your Maven repository. This leads me to these questions: (1) How can I include classes from other modules in my jar? Thanks to Wayne Fay for pointing out the shade plugin. It does this, but I couldn't figure out how to set the classpath with the shade plugin. Build a jar with just the common classes. (2) How can I add arbitrary jars, in arbitrary directories, to my Class-Path entry in my jar? I've now managed this: plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-jar-plugin/artifactId configuration archive manifestEntries Class-Path${libdir}/path/to/lib1.jar ${libdir}/path/to/lib2.jar ... /Class-Path Main-Classcanonical.name.of.MainClass/Main-Class /manifestEntries /archive /configuration /plugin Before figuring out this, I tried declaring the lib?.jars using dependencies with system scope but they did not get included in the Class-Path entry in the jar's META-INF/MANIFEST.MF, even though I did set manifestaddClasspathtrue/addClasspath/manifest -- any ideas why that didn't work? Use maven to define your dependencies as dependencies in your pom (1) has been my usual solution to the problem that classes cannot be provided by jars inside jars, but if it's possible to include the absolute paths to jars built by other modules that would probably be ok. Not a good idea. just declare your dependencies. (2) referencing those other jars by absolute path would be ok for my purpose. Use Maven to define your jars. Do not try to tell maven absolute paths. I understand the sentiment of prefering to let Maven handle such things, but that's not always practical or desirable. For my purpose there's just no way how Maven (or anything else) could automagically find libdir, so setting that as a property in the top-level pom.xml or via an environment variable is quite reasonable. I guess my general question is: How do you build standalone executable jars that don't depend on other jars moving along with them? You create jars that include all of the dependencies that are required. Please see above -- if system-scoped dependencies did produce the right classpath entries I'd prefer to use them. Best regards, Jan -- +- Jan T. Kim ---+ | email: j@uea.ac.uk | | WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Building standalone jars
Dear All, I need to build a standalone executable jar and have the following difficulties: * the app needs a bunch of classes from another module * the app needs classes provided by non-Maven jars This leads me to these questions: (1) How can I include classes from other modules in my jar? (2) How can I add arbitrary jars, in arbitrary directories, to my Class-Path entry in my jar? (1) has been my usual solution to the problem that classes cannot be provided by jars inside jars, but if it's possible to include the absolute paths to jars built by other modules that would probably be ok. (2) referencing those other jars by absolute path would be ok for my purpose. I guess my general question is: How do you build standalone executable jars that don't depend on other jars moving along with them? Best regards, Jan -- +- Jan T. Kim ---+ | email: j@uea.ac.uk | | WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Building standalone jars
I guess my general question is: How do you build standalone executable jars that don't depend on other jars moving along with them? Shade plugin. Wayne - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Building standalone jars
Everyone should be used to using Classes that are grouped into libraries. Jan T. Kim wrote: Dear All, I need to build a standalone executable jar and have the following difficulties: * the app needs a bunch of classes from another module break the other module into a jar that contains the sharable classes and an application that depends on that jar * the app needs classes provided by non-Maven jars Get Nexus and load the non-Maven, non-yours jars into your Maven repository. This leads me to these questions: (1) How can I include classes from other modules in my jar? Build a jar with just the common classes. (2) How can I add arbitrary jars, in arbitrary directories, to my Class-Path entry in my jar? Use maven to define your dependencies as dependencies in your pom (1) has been my usual solution to the problem that classes cannot be provided by jars inside jars, but if it's possible to include the absolute paths to jars built by other modules that would probably be ok. Not a good idea. just declare your dependencies. (2) referencing those other jars by absolute path would be ok for my purpose. Use Maven to define your jars. Do not try to tell maven absolute paths. I guess my general question is: How do you build standalone executable jars that don't depend on other jars moving along with them? You create jars that include all of the dependencies that are required. Best regards, Jan - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org