You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2021/05/09 08:25:33 UTC
[maven-war-plugin] branch master updated: [MWAR-441] add
outdatedCheckPath=/ to cover everything in the web app
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 17e71f8 [MWAR-441] add outdatedCheckPath=/ to cover everything in the web app
17e71f8 is described below
commit 17e71f8569c7c236ba7f918095942e3e26861c55
Author: Scott Kurz <sk...@us.ibm.com>
AuthorDate: Thu May 6 11:49:36 2021 -0400
[MWAR-441] add outdatedCheckPath=/ to cover everything in the web app
---
src/it/MWAR-441/invoker.properties | 20 +++++
src/it/MWAR-441/pom.xml | 87 ++++++++++++++++++++++
src/it/MWAR-441/src/main/resources/resource.txt | 16 ++++
src/it/MWAR-441/src/main/webapp/root.html | 23 ++++++
src/it/MWAR-441/verify.groovy | 26 +++++++
.../apache/maven/plugins/war/AbstractWarMojo.java | 16 +++-
6 files changed, 185 insertions(+), 3 deletions(-)
diff --git a/src/it/MWAR-441/invoker.properties b/src/it/MWAR-441/invoker.properties
new file mode 100644
index 0000000..ea3a622
--- /dev/null
+++ b/src/it/MWAR-441/invoker.properties
@@ -0,0 +1,20 @@
+# 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.
+
+invoker.goals.1=package
+invoker.goals.2=groovy:execute
+invoker.goals.3=package
diff --git a/src/it/MWAR-441/pom.xml b/src/it/MWAR-441/pom.xml
new file mode 100644
index 0000000..261c77c
--- /dev/null
+++ b/src/it/MWAR-441/pom.xml
@@ -0,0 +1,87 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.war</groupId>
+ <artifactId>mwar427</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <archiveClasses>true</archiveClasses>
+ <outdatedCheckPath>/</outdatedCheckPath>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <source>
+ def fileToModify = new File(project.basedir, 'pom.xml')
+ processFileInplace(fileToModify) { text ->
+ text.replaceAll(/1.4.6/,'1.4.5')
+ }
+ def processFileInplace(file, Closure processText) {
+ file.write(processText(file.text))
+ }
+
+ new File('src/main/webapp/root.html').renameTo 'src/main/webapp/index.html'
+ </source>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>2.4.21</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.4.6</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/src/it/MWAR-441/src/main/resources/resource.txt b/src/it/MWAR-441/src/main/resources/resource.txt
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/src/it/MWAR-441/src/main/resources/resource.txt
@@ -0,0 +1,16 @@
+# 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.
diff --git a/src/it/MWAR-441/src/main/webapp/root.html b/src/it/MWAR-441/src/main/webapp/root.html
new file mode 100644
index 0000000..8809bcf
--- /dev/null
+++ b/src/it/MWAR-441/src/main/webapp/root.html
@@ -0,0 +1,23 @@
+<!--
+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.
+-->
+<html>
+ <body>
+ Hello World
+ </body>
+</html>
\ No newline at end of file
diff --git a/src/it/MWAR-441/verify.groovy b/src/it/MWAR-441/verify.groovy
new file mode 100644
index 0000000..f9cabc9
--- /dev/null
+++ b/src/it/MWAR-441/verify.groovy
@@ -0,0 +1,26 @@
+/*
+ * 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 warFile = new java.util.jar.JarFile( new File(basedir,"target/mwar427-1.0-SNAPSHOT.war"), false)
+assert warFile.getEntry('WEB-INF/lib/plexus-utils-1.4.5.jar') != null
+assert warFile.getEntry('WEB-INF/lib/mwar427-1.0-SNAPSHOT.jar') != null
+assert warFile.getEntry('index.html') != null
+
+assert warFile.getEntry('WEB-INF/lib/plexus-utils-1.4.6.jar') == null
+assert warFile.getEntry('root.html') == null // after MWAR-441, this path is also removed as outdated (with the '/' config in the pom).
diff --git a/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java b/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java
index 0bded3c..d0be97a 100644
--- a/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java
@@ -365,6 +365,9 @@ public abstract class AbstractWarMojo
/**
* Path prefix for resources that will be checked against outdated content.
*
+ * Starting with <b>3.3.2</b>, if a value of "/" is specified the entire
+ * webappDirectory will be checked, i.e. the "/" signifies "root".
+ *
* @since 3.3.1
*/
@Parameter( defaultValue = "WEB-INF/lib/" )
@@ -650,7 +653,10 @@ public abstract class AbstractWarMojo
{
if ( '\\' == File.separatorChar )
{
- outdatedCheckPath = outdatedCheckPath.replace( '/', '\\' );
+ if ( ! checkAllPathsForOutdated() )
+ {
+ outdatedCheckPath = outdatedCheckPath.replace( '/', '\\' );
+ }
}
Files.walkFileTree( webappDirectory.toPath(), new SimpleFileVisitor<Path>()
{
@@ -660,9 +666,8 @@ public abstract class AbstractWarMojo
{
if ( file.toFile().lastModified() < session.getStartTime().getTime() )
{
- // resource older than session build start
String path = webappDirectory.toPath().relativize( file ).toString();
- if ( path.startsWith( outdatedCheckPath ) )
+ if ( checkAllPathsForOutdated() || path.startsWith( outdatedCheckPath ) )
{
outdatedResources.add( path );
}
@@ -679,6 +684,11 @@ public abstract class AbstractWarMojo
this.outputTimestamp = outputTimestamp;
}
+ protected boolean checkAllPathsForOutdated()
+ {
+ return outdatedCheckPath.equals( "/" );
+ }
+
@Override
public MavenProject getProject()
{