Reputation: 738
I am trying to add some filtering to the Spring
application context file, which resides in src/main/resources
folder but it's not working. I put my filter file in src/main/filters
I've tried many solutions but none are working when i launch unit test through maven install or junit but if i skip test it's filtering it's working .
I've modified the file .classPath
, I removed exclude
attribute from the file
edit classpath solution then I read this article bug in maven-resources-plug who said that there is a bug in maven-resources-plugin so I updated the plugin to a newer version but it's still not working.
My pom.xml :
<build>
<finalName>core-impl</finalName>
<directory>target</directory>
<sourceDirectory>src/main/java</sourceDirectory>
<outputDirectory>target/classes</outputDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/filter.properties</filter>
</filters>
</build>
Upvotes: 1
Views: 3360
Reputation: 738
i tried this solution and it's working .
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>${basedir}/src/main/filters/filter.properties</filter>
</filters>
</configuration>
</execution>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>${basedir}/src/test/filters/filter.properties</filter>
</filters>
</configuration>
</execution>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<filtering>true</filtering>
<directory>src/test/resources</directory>
</testResource>
</testResources>
Upvotes: 2