jQuery in Action, 3rd edition
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
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "maven - resources files" Watch "maven - resources files" New topic

maven - resources files

igor kvak

Joined: May 28, 2008
Posts: 17
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

Joined: May 14, 2008
Posts: 5852

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

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
It's not a secret anymore!