This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Copy any properties files to classes folder using maven Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Copy any properties files to classes folder using maven" Watch "Copy any properties files to classes folder using maven" New topic
Author

Copy any properties files to classes folder using maven

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Hi,

I have few properties files in my source folders..

src-main-java-com.xyz.business.forms

now when i install the war its able to get all java classes into the target but not the properties files. What should be done to get these properties files also..

Regards
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

In a typical maven project directory structure, resource files, such as properties file, should be placed in src/main/resources. For example, if you have a properties file named com.xyz.business.forms.properties, it should be located at:

src/main/resources/com/xyz/business/forms.properties

Maven will then automatically pick up the properties file and add it to the JAR or WAR file.


JBoss In Action
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
i agree that typically we are supposed to use resources folder..
but these properties files are used by these classes and they have be present in those folders only..
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
But cant we have them in the same folder structure as in java..

rather than in having them in... resources/com/xyz/business/..

and build them
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

but these properties files are used by these classes and they have be present in those folders only


The resources will be copied into the same target/classes directory as your compiled classes, and thus classes and resources will reside in the same folder. It is only during editing time that the java source file and resources appear in different locations.
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Thanks Peter !!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Copy any properties files to classes folder using maven