This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes maven - resources files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "maven - resources files" Watch "maven - resources files" New topic
Author

maven - resources files

igor kvak
Greenhorn

Joined: May 28, 2008
Posts: 17
Hi
I am trying to create jar with maven and I want also all resources (all .properties files and I have also .png files) to be included
right now all non-java (.class) files are ignored

here is part of my pom.xml file:


and here is also assembly.xml:


There is an article about resources on maven page, but they have all their resources in directery named "resources" and I do not want to do this way

could you help me, how to add resources (in my case .properties and .png files) into jar file?

thanks a lot


Never trouble trouble till trouble troubles you
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

All of you java source should go at src/main/java. All of your resource files should go in src/main/resources. When the build runs, during the process-resources phase the resource are copied to target/classes. Similarly, during the compile phase, the Java source are compiled into target/classes. Then during the package phase, all of the files in target/classes (both resource files and class files) are packaged into a JAR file. This standard Maven practice and you should not try to subvert that (unless you like causing yourself much grief and anguish.)

If you are trying to use the assembly plugin to create the JAR file, you are doing it wrong. The assembly plugin is meant to create an installation or distribution package of your product, it is not meant to build the artifact (JAR file) for the project.


JBoss In Action
igor kvak
Greenhorn

Joined: May 28, 2008
Posts: 17
thanks a lot - it works now

I use assembly plugin to copy all libraries to lib/ directory
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: maven - resources files