Skip to content

Commit 364679a

Browse files
lprimakslawekjaranowski
authored andcommitted
bugfix: regression due to targetPath interfering with the exclusion logic
1 parent 9f49876 commit 364679a

File tree

8 files changed

+176
-2
lines changed

8 files changed

+176
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals=clean package

src/it/war-resources/pom.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
<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">
21+
<modelVersion>4.0.0</modelVersion>
22+
<groupId>test</groupId>
23+
<artifactId>war-resources</artifactId>
24+
<version>1.0-SNAPSHOT</version>
25+
<packaging>war</packaging>
26+
<name>Maven War Resources Project Test</name>
27+
<description>maven test it</description>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<artifactId>maven-war-plugin</artifactId>
33+
<version>@pom.version@</version>
34+
<configuration>
35+
<webResources>
36+
<resource>
37+
<directory>src/main/extra</directory>
38+
<targetPath>/</targetPath>
39+
<filtering>false</filtering>
40+
</resource>
41+
</webResources>
42+
</configuration>
43+
</plugin>
44+
</plugins>
45+
</build>
46+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<%--
2+
~ Licensed to the Apache Software Foundation (ASF) under one
3+
~ or more contributor license agreements. See the NOTICE file
4+
~ distributed with this work for additional information
5+
~ regarding copyright ownership. The ASF licenses this file
6+
~ to you under the Apache License, Version 2.0 (the
7+
~ "License"); you may not use this file except in compliance
8+
~ with the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing,
13+
~ software distributed under the License is distributed on an
14+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
~ KIND, either express or implied. See the License for the
16+
~ specific language governing permissions and limitations
17+
~ under the License.
18+
--%>
19+
20+
<html>
21+
<body>
22+
<h2>Hello World from another!</h2>
23+
</body>
24+
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<!DOCTYPE web-app PUBLIC
21+
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
22+
"http://java.sun.com/dtd/web-app_2_3.dtd" >
23+
24+
<web-app>
25+
<display-name>Archetype Created Web Application</display-name>
26+
</web-app>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<%--
2+
~ Licensed to the Apache Software Foundation (ASF) under one
3+
~ or more contributor license agreements. See the NOTICE file
4+
~ distributed with this work for additional information
5+
~ regarding copyright ownership. The ASF licenses this file
6+
~ to you under the Apache License, Version 2.0 (the
7+
~ "License"); you may not use this file except in compliance
8+
~ with the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing,
13+
~ software distributed under the License is distributed on an
14+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
~ KIND, either express or implied. See the License for the
16+
~ specific language governing permissions and limitations
17+
~ under the License.
18+
--%>
19+
20+
<html>
21+
<body>
22+
<h2>Hello World!</h2>
23+
</body>
24+
</html>

src/it/war-resources/verify.groovy

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
def warFile = new java.util.jar.JarFile( new File(basedir,"target/war-resources-1.0-SNAPSHOT.war"), false)
21+
assert warFile.getEntry('WEB-INF/web.xml') != null
22+
assert warFile.getEntry('index.jsp') != null
23+
assert warFile.getEntry('another.jsp') != null

src/main/java/org/apache/maven/plugins/war/packaging/AbstractWarPackagingTask.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,23 @@ protected void copyFiles(
148148
*/
149149
// CHECKSTYLE_OFF: LineLength
150150
protected void copyFile(String sourceId, final WarPackagingContext context, final File file, String targetFilename)
151+
throws IOException {
152+
copyFile(sourceId, context, file, targetFilename, targetFilename);
153+
}
154+
155+
/**
156+
* Adds originalFilename for exclusion checks.
157+
*/
158+
void copyFile(
159+
String sourceId,
160+
final WarPackagingContext context,
161+
final File file,
162+
String targetFilename,
163+
String originalFilename)
151164
throws IOException
152165
// CHECKSTYLE_ON: LineLength
153166
{
154-
if (isExcluded(targetFilename, context.getPackagingIncludes(), context.getPackagingExcludes())) {
167+
if (isExcluded(originalFilename, context.getPackagingIncludes(), context.getPackagingExcludes())) {
155168
context.getLog().debug("Skipping excluded file: " + targetFilename);
156169
return;
157170
}

src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public void copyResources(WarPackagingContext context, Resource resource)
306306
if (resource.isFiltering() && !context.isNonFilteredExtension(fileName)) {
307307
copyFilteredFile(id, context, new File(resource.getDirectory(), fileName), targetFileName);
308308
} else {
309-
copyFile(id, context, new File(resource.getDirectory(), fileName), targetFileName);
309+
copyFile(id, context, new File(resource.getDirectory(), fileName), targetFileName, fileName);
310310
}
311311
}
312312
}

0 commit comments

Comments
 (0)