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 2020/06/13 14:56:40 UTC

[maven-war-plugin] branch MWAR-434 created (now 6e4a16a)

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a change to branch MWAR-434
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git.


      at 6e4a16a  [MWAR-434] remove jar created by archiveClasses from outdated files

This branch includes the following new commits:

     new 6e4a16a  [MWAR-434] remove jar created by archiveClasses from outdated files

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-war-plugin] 01/01: [MWAR-434] remove jar created by archiveClasses from outdated files

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MWAR-434
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git

commit 6e4a16a2197ee4467aaf2021d6c996b9e8981991
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Jun 13 16:56:35 2020 +0200

    [MWAR-434] remove jar created by archiveClasses from outdated files
---
 src/it/MWAR-427_update-without-clean/pom.xml             |  3 +++
 .../src/main/resources/resource.txt                      | 16 ++++++++++++++++
 src/it/MWAR-427_update-without-clean/verify.groovy       |  1 +
 .../org/apache/maven/plugins/war/AbstractWarMojo.java    |  4 ++--
 .../plugins/war/packaging/ClassesPackagingTask.java      |  4 +++-
 .../plugins/war/packaging/WarProjectPackagingTask.java   |  5 ++---
 6 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/src/it/MWAR-427_update-without-clean/pom.xml b/src/it/MWAR-427_update-without-clean/pom.xml
index 88a9fad..a0d7146 100644
--- a/src/it/MWAR-427_update-without-clean/pom.xml
+++ b/src/it/MWAR-427_update-without-clean/pom.xml
@@ -37,6 +37,9 @@ under the License.
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-war-plugin</artifactId>
         <version>@project.version@</version>
+        <configuration>
+          <archiveClasses>true</archiveClasses>
+        </configuration>
       </plugin>
       <plugin>
         <groupId>org.codehaus.gmaven</groupId>
diff --git a/src/it/MWAR-427_update-without-clean/src/main/resources/resource.txt b/src/it/MWAR-427_update-without-clean/src/main/resources/resource.txt
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/src/it/MWAR-427_update-without-clean/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-427_update-without-clean/verify.groovy b/src/it/MWAR-427_update-without-clean/verify.groovy
index 8946fb4..5fdf474 100644
--- a/src/it/MWAR-427_update-without-clean/verify.groovy
+++ b/src/it/MWAR-427_update-without-clean/verify.groovy
@@ -19,6 +19,7 @@
 
 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
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 ac63901..58f7840 100644
--- a/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java
@@ -97,8 +97,8 @@ public abstract class AbstractWarMojo
 
     /**
      * Whether a JAR file will be created for the classes in the webapp. Using this optional configuration parameter
-     * will make the compiled classes to be archived into a JAR file and the classes directory will then be excluded
-     * from the webapp.
+     * will make the compiled classes to be archived into a JAR file in <code>/WEB-INF/lib/</code> and the classes
+     * directory will then be excluded from the webapp <code>/WEB-INF/classes/</code>.
      *
      * @since 2.0.1
      */
diff --git a/src/main/java/org/apache/maven/plugins/war/packaging/ClassesPackagingTask.java b/src/main/java/org/apache/maven/plugins/war/packaging/ClassesPackagingTask.java
index 4456df0..da3b579 100644
--- a/src/main/java/org/apache/maven/plugins/war/packaging/ClassesPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugins/war/packaging/ClassesPackagingTask.java
@@ -34,7 +34,7 @@ import java.io.IOException;
 /**
  * Handles the classes directory that needs to be packaged in the web application.
  * 
- * Based on the {@link WarPackagingContext#archiveClasses()} flag the resources either copied into to
+ * Based on the {@link WarPackagingContext#archiveClasses()} flag, the resources are either copied into to
  * <tt>WEB-INF/classes</tt> directory or archived in a jar within the <tt>WEB-INF/lib</tt> directory.
  *
  * @author Stephane Nicoll
@@ -110,6 +110,8 @@ public class ClassesPackagingTask
 
         if ( context.getWebappStructure().registerFile( currentProjectOverlay.getId(), targetFilename ) )
         {
+            context.getOutdatedResources().remove( targetFilename.replace( '/', File.separatorChar ) );
+
             final File libDirectory = new File( context.getWebappDirectory(), LIB_PATH );
             final File jarFile = new File( libDirectory, archiveName );
             final ClassesPackager packager = new ClassesPackager();
diff --git a/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java b/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java
index 686a038..02aea9e 100644
--- a/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java
@@ -114,9 +114,8 @@ public class WarProjectPackagingTask
         {
             for ( String resource : context.getOutdatedResources() )
             {
-                File outdated = new File( context.getWebappDirectory(), resource );
-                context.getLog().debug( "deleting outdated resource " + outdated );
-                outdated.delete();
+                context.getLog().info( "deleting outdated resource " + resource );
+                new File( context.getWebappDirectory(), resource ).delete();
             }
         }
     }