[MWAR-311]
- Fixed problem with project filtering
verified by integration test by Evan Brodie.
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1601568 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 6ef911a..37c013c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -250,48 +250,45 @@
<profile>
<id>run-its</id>
<build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-invoker-plugin</artifactId>
- <configuration>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <configuration>
+ <goals>
+ <goal>clean</goal>
+ <goal>package</goal>
+ </goals>
+ <projectsDirectory>src/it</projectsDirectory>
+ <postBuildHookScript>verify</postBuildHookScript>
+ <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ </configuration>
+ <executions>
+ <execution>
+ <id>install</id>
+ <phase>pre-integration-tests</phase>
<goals>
- <goal>clean</goal>
- <goal>package</goal>
+ <goal>install</goal>
</goals>
- <projectsDirectory>src/it</projectsDirectory>
- <postBuildHookScript>verify</postBuildHookScript>
- <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
- <settingsFile>src/it/settings.xml</settingsFile>
- <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
- </configuration>
- <executions>
- <execution>
- <id>install</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>install</goal>
- </goals>
- <configuration>
- <extraArtifacts>
- <extraArtifact>javax.servlet:servlet-api:2.4:jar</extraArtifact>
- <extraArtifact>org.apache.struts:struts-core:1.3.9:jar</extraArtifact>
- <extraArtifact>org.codehaus.plexus:plexus-utils:1.4.7:jar:sources</extraArtifact>
- </extraArtifacts>
- </configuration>
- </execution>
- <execution>
- <id>go</id>
- <phase>integration-test</phase>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </pluginManagement>
+ <configuration>
+ <extraArtifacts>
+ <extraArtifact>javax.servlet:servlet-api:2.4:jar</extraArtifact>
+ <extraArtifact>org.apache.struts:struts-core:1.3.9:jar</extraArtifact>
+ <extraArtifact>org.codehaus.plexus:plexus-utils:1.4.7:jar:sources</extraArtifact>
+ </extraArtifacts>
+ </configuration>
+ </execution>
+ <execution>
+ <id>verify</id>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
</profile>
</profiles>
diff --git a/src/it/MWAR-311/pom.xml b/src/it/MWAR-311/pom.xml
new file mode 100644
index 0000000..820173b
--- /dev/null
+++ b/src/it/MWAR-311/pom.xml
@@ -0,0 +1,64 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.ecbrodie</groupId>
+ <artifactId>MWAR-311</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>Maven War Plugin Bug</name>
+ <description>Filtering of properties files (as a web resource) broken in maven-war-plugin version 2.4.</description>
+ <packaging>war</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <my.maven.property>foo foo</my.maven.property>
+ </properties>
+
+ <build>
+ <filters>
+ <filter>src/main/resources/default.properties</filter>
+ </filters>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <webResources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/app.properties</include>
+ </includes>
+ </resource>
+ </webResources>
+ <archiveClasses>true</archiveClasses>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/MWAR-311/src/main/resources/app.properties b/src/it/MWAR-311/src/main/resources/app.properties
new file mode 100644
index 0000000..06f1c91
--- /dev/null
+++ b/src/it/MWAR-311/src/main/resources/app.properties
@@ -0,0 +1,3 @@
+my.maven.property=${my.maven.property}
+prop.a=${prop.a}
+prop.b=${prop.b}
diff --git a/src/it/MWAR-311/src/main/resources/default.properties b/src/it/MWAR-311/src/main/resources/default.properties
new file mode 100644
index 0000000..4547528
--- /dev/null
+++ b/src/it/MWAR-311/src/main/resources/default.properties
@@ -0,0 +1,2 @@
+prop.a=AAA
+prop.b=BBB
diff --git a/src/it/MWAR-311/src/main/webapp/WEB-INF/web.xml b/src/it/MWAR-311/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..87b201c
--- /dev/null
+++ b/src/it/MWAR-311/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+</web-app>
\ No newline at end of file
diff --git a/src/it/MWAR-311/verify.groovy b/src/it/MWAR-311/verify.groovy
new file mode 100644
index 0000000..7759989
--- /dev/null
+++ b/src/it/MWAR-311/verify.groovy
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+def propertiesFile = new File(basedir, 'target/MWAR-311-0.0.1-SNAPSHOT/app.properties');
+assert propertiesFile.exists()
+
+assert propertiesFile.text.contains('my.maven.property=foo foo');
+assert propertiesFile.text.contains('prop.a=AAA');
+assert propertiesFile.text.contains('prop.b=BBB');
diff --git a/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java b/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
index 0a0ae6e..f87d3f3 100644
--- a/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
+++ b/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
@@ -474,6 +474,9 @@
mavenResourcesExecution.setEscapeString( escapeString );
mavenResourcesExecution.setSupportMultiLineFiltering( supportMultiLineFiltering );
mavenResourcesExecution.setMavenProject( project );
+ if (filters == null) {
+ filters = getProject().getBuild().getFilters();
+ }
mavenResourcesExecution.setFilters( filters );
mavenResourcesExecution.setEscapedBackslashesInFilePath( escapedBackslashesInFilePath );
mavenResourcesExecution.setMavenSession( this.session );