Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maven add classes to jar

 
kartik krishnan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • 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,
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Well,

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

My apologies.

Krishnan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic