Search code examples
eclipsemavenm2eclipsetapestrym2e

How to keep in sync the resources of two folders with Maven


I use Eclipse + Maven and - for unit testing purposes - the web framework I am working with (Tapestry 5) requires that view elements (*.tml) that are in src/main/resources also be present in src/test/resources.

I am not sure how to make sure they are present simultaneously in both folders.

Can anyone please help?


Solution

  • Your resource files don't have to be in both locations just so that Maven can find them. Instead, you can just tell Maven that you've also put some in the src/main/java folder. Put this snippet into the build section of your POM:

    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
    

    For more information, take a look at the relevant sections in the Maven Resources plugin documentation.