How To Change Maven's Default Resource Folder |
Sometimes it's nice to have your projects resource files alongside the java source files they're related to. By default, Maven forces you to have a separate resource tree so, for example, whenever you need to a add a String for internationalization you have to go digging through your project's folders.
The good news is, you can change change maven's default resource folder this with this little bit of XML magic in Maven pom.xml.
<build> <resources> <resource> <directory>src/main/java</directory> <excludes><exclude>**/*.java</exclude></excludes> </resource> </resources> </build>
Note this overrides the default location, so make sure src/main/resources is empty, or add to the pom.xml like this.
<build> <resources> <resource> <directory>src/main/java</directory> <excludes><exclude>**/*.java</exclude></excludes> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> </build>
Don't forget to exclude the java files unless you want to ship your source code!
How To Change Maven's Default Resource FolderRoger Keays is an artist, an engineer, and a student of life. He has no fixed address and has left footprints on 40-something different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, the proper use of semicolons, and finding good food. |