views:

40

answers:

2

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.

A: 

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.

Pascal Thivent
A: 

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>
seanizer
Thanks, Seanizer. That was what I was looking for. I agree with Pascal, but this is a legacy application with a very deep package structure. Moving the resources (property files) to a parallel folder in the resources folder would not have helped project comprehension.
steve217
Uhm then I suggest an upvote and / or an accept. :-)
seanizer
I accept- ?. Don't have the rep yet to upvote.
steve217
thank you very much :-).
seanizer