Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven exclude resources not working

Tags:

java

maven

I googled for my issue but I was not able in finding solution; I'm using maven 3.1.2 I have this profile in my pom.xml

<profile>
            <id>test</id>
            <build>
                <finalName>CustomWebAppName</finalName>
                <resources>         
                    <resource>
                        <directory>src/main/resources</directory>
                        <excludes>
                            <exclude>environmentConfiguration.properties</exclude>
                        </excludes>
                    </resource>
                    <resource>
                        <directory>resourcesTest</directory>
                        <includes>
                            <include>environmentConfiguration.properties</include>
                        </includes>                     
                    </resource>                     
                </resources>                
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>2.4</version>
                        <configuration>
                            <outputDirectory>testDist</outputDirectory>
                            <warSourceDirectory>WebContent</warSourceDirectory>
                        </configuration>
                    </plugin>
                </plugins>              
            </build>
        </profile>

As you can see I'm simply telling maven: when you build the test profile you must ignore the file "environmentConfiguration.properties" in folder src/main/resources and consider the file "environmentConfiguration.properties" in resourcesTest

Well when I launch the command mvn clean install -P test my final web application always contains the "environmentConfiguration.properties" file located in src/main/resources and doesn't contain the one in resourcesTest I add to the question my fully debug log file generated by maven Please note this file will be available till November 12nd 2015

Can anybody tell me where I'm wrong?

thank you Angelo

like image 206
Angelo Immediata Avatar asked May 14 '26 23:05

Angelo Immediata


1 Answers

I don't know exactly whether this is your problem or a typo in your question but there shouldn't be any space between -P and test

try this instead

mvn clean install -Ptest

EDIT

try to enable filtering

<profile>
            <id>test</id>
            <build>
                <finalName>CustomWebAppName</finalName>
                <resources>         
                    <resource>
                        <directory>src/main/resources</directory>
                        <filtering>true</filtering>
                        <excludes>
                            <exclude>environmentConfiguration.properties</exclude>
                        </excludes>
                    </resource>
                    <resource>
                        <directory>resourcesTest</directory>
                        <filtering>true</filtering>
                        <includes>
                            <include>environmentConfiguration.properties</include>
                        </includes>                     
                    </resource>                     
                </resources>                
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>2.4</version>
                        <configuration>
                            <outputDirectory>testDist</outputDirectory>
                            <warSourceDirectory>WebContent</warSourceDirectory>
                        </configuration>
                    </plugin>
                </plugins>              
            </build>
        </profile>
like image 171
Amin Abu-Taleb Avatar answered May 17 '26 12:05

Amin Abu-Taleb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!