Non-java resources disappear from class package after maven packaging

35 Views Asked by At

I'm trying to create a Spring project structure where I have my HTML templates stored in the same src/main/java package (in Tapestry-like way), so the structure basically looks like this:

src/main/java
            -org
               -example
                  -views
                     -pageOne
                         PageOneController.java
                         Template.html
                     -pageTwo
                         PageTwoController.java
                         Template.html

However after packaging a WAR while using Maven I get a structure like this:

WEB-INF/classes
              -org
                 -example
                    -views
                       -pageOne
                           PageOneController.class
                       -pageTwo
                           PageTwoController.class

So the .html files are ignored and obviously nothing works. I tried to configure maven-resources-plugin to copy those resources like this:

<build>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <filtering>false</filtering>
            <includes>
                <include>*/**.html</include>
            </includes>
            <excludes>
                <exclude>*/**.java</exclude>
            </excludes>
        </resource>
    </resources>
</build>

but to no avail.

How do I configure my project to copy non-java files from src/main/java into the final output?

1

There are 1 best solutions below

0
Pavel Polyakoff On

It turns out that the problem was with maven modules. I have declared resources plugin in the main pom.xml instead of the module's pom.xml which lead to the configuration issues.