• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Maven add classes to jar

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am a Maven newbie so I would like to seek some help there. I have just joined a new project. It's structure unlike what is advised in all the Maven tutorials.

I would like to build the project structure which is defined as follows

Project Home . We have two folders under that

java and unittests.


Out requirements are that we would like to build a module.jar which holds all the class files including all the dependencies unjared and put into the single jar.

I am unable to figure out how to do this. I have looked at the Maven forums but unfortunately, I can not understand how to do this.

Please help me here.

Thanks,
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't define the directory structure and have Maven build your project... you have Maven build the directory structure and fit the parts of your project into the pre-determined locations.

It *is* possible to change the directory structure, but more problems than it is worth... and not guaranteed to work with all Maven plugins.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nate's right. You CAN override the standard Maven directory conventions, but you'd probably regret it. I don't like them myself, but at least they're a standard that anyone can come in and take over the project with minimal learning.

The standard project structure for a JAR project looks something like this:

If you explode your dependency classes and put them in the main resources directory, they should copy into the final jar.

How you get them exploded is up to you. If you are working with a fixed set of jars, you can put them in a library directory, write an ant sub-task to explode them and let Maven take over. If you're attempting to use Maven-managed libraries, you'd probably have to do more work (or copy them into the above-mentioned library source directory).

There MIGHT be a jar-combiner Maven option, but I don't know of any. Not that that means much.
[ February 05, 2008: Message edited by: Tim Holloway ]
 
kartik krishnan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well,

I saw this link Maven Build Settings and I assumed that it was possible.

My apologies.

Krishnan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic