Search code examples
eclipsemaven-2m2eclipse

Missing package property files in war build


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.


Solution

  • 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>