Reputation: 45
Littered throughout my project are various property files located in packages that are not being included when the package goal is run from a Maven build.
Using the 0.10.2 m2eclipse plugin and the default "package" goal.
In the project:
src->main->java->mypackage->MyProperties.java
src->main->java->mypackage->MyProperties.properties
In expanded war directory after the "package" goal is run:
target->classes->mypackage->MyProperties.class
-- no property file --
I'm trying to get the group to adopt Maven and resolving this issue is going to be a deal maker. Moving the properties files isn't going to be practical. Any help is much appreciated.
Upvotes: 4
Views: 1903
Reputation: 58
I had same problem. Solution was check Build Path of project at Eclipse. At "source" look for "yourProject/src/main/resources". The node "Excluded: **" here you remove the filter, apply and build again with Maven. Then enable the filter again and runs like a charme with all property-files.
Hope this helps
Upvotes: 0
Reputation: 58
Me helped to check build path. The rpoperties of resources were excluded. When I included them again, the war got all property-files from resource and tomcat deployed correct.
Upvotes: 0
Reputation: 299148
Pascal's answer is the correct maven way of doing things.
But some developers like to keep resources next to their sources (it's standard procedure in wicket, for example).
If you're going to do that, you will have to add your source folder to the resources:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>
Upvotes: 2
Reputation: 570565
Put your property files where Application/Library resources belong, i.e. in src/main/resources
:
src/main/resources/mypackage/MyProperties.properties
And it will get copied properly.
Upvotes: 5