You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2016/01/25 20:27:24 UTC

svn commit: r1726671 - in /maven/plugins/trunk/maven-war-plugin/src: it/MWAR-350/ it/MWAR-350/src/ it/MWAR-350/src/main/ it/MWAR-350/src/main/java/ it/MWAR-350/src/main/java/org/ it/MWAR-350/src/main/java/org/apache/ it/MWAR-350/src/main/java/org/apach...

Author: khmarbaise
Date: Mon Jan 25 19:27:24 2016
New Revision: 1726671

URL: http://svn.apache.org/viewvc?rev=1726671&view=rev
Log:
[MWAR-350] Add Skip Parameter to Skip the process

Added:
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/pom.xml
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/java/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/java/org/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/java/org/apache/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/java/org/apache/maven/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/java/org/apache/maven/it0016/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/java/org/apache/maven/it0016/Person.java
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/WEB-INF/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/WEB-INF/web.xml
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/index.html
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/verify.bsh
Modified:
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java

Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/pom.xml?rev=1726671&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/pom.xml (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/pom.xml Mon Jan 25 19:27:24 2016
@@ -0,0 +1,69 @@
+<?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>maven-it-mwar350</artifactId>
+  <version>1.0</version>
+  <packaging>war</packaging>
+
+  <name>Maven Integration Test :: MWAR-350</name> 
+  <description>Test to skip WAR generation</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>2.4</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.3</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/java/org/apache/maven/it0016/Person.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/java/org/apache/maven/it0016/Person.java?rev=1726671&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/java/org/apache/maven/it0016/Person.java (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/java/org/apache/maven/it0016/Person.java Mon Jan 25 19:27:24 2016
@@ -0,0 +1,35 @@
+package org.apache.maven.it0016;
+
+/*
+ * 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.
+ */
+
+public class Person
+{
+    private String name;
+    
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+    
+    public String getName()
+    {
+        return name;
+    }
+}

Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/WEB-INF/web.xml?rev=1726671&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/WEB-INF/web.xml (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/WEB-INF/web.xml Mon Jan 25 19:27:24 2016
@@ -0,0 +1,23 @@
+<?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.
+-->
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app >
+</web-app>

Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/index.html?rev=1726671&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/index.html (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/src/main/webapp/index.html Mon Jan 25 19:27:24 2016
@@ -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>

Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/verify.bsh?rev=1726671&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/verify.bsh (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-350/verify.bsh Mon Jan 25 19:27:24 2016
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+import java.util.regex.*;
+
+try
+{
+    File explodedDir = new File( basedir, "target/maven-it-mwar350-1.0" );
+    System.out.println( "Checking for existence of exploded directory " + explodedDir );
+    if ( explodedDir.isDirectory() )
+    {
+        System.out.println( "FAILURE! The directory " + explodedDir + " does exist." );
+        return false;
+    }
+
+
+    File warFile = new File( basedir, "target/maven-it-mwar350-1.0.war" );
+    System.out.println( "Checking for existence of " + warFile );
+    if ( warFile.isFile() )
+    {
+        System.out.println( "FAILURE! The generated file should have not be there." );
+        return false;
+    }
+
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java?rev=1726671&r1=1726670&r2=1726671&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java Mon Jan 25 19:27:24 2016
@@ -1,5 +1,9 @@
 package org.apache.maven.plugin.war;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -38,10 +42,6 @@ import org.codehaus.plexus.archiver.war.
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-
 /**
  * Build a WAR file.
  *
@@ -50,7 +50,7 @@ import java.util.Arrays;
  */
 // CHECKSTYLE_OFF: LineLength
 @Mojo( name = "war", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true, requiresDependencyResolution = ResolutionScope.RUNTIME )
-//CHECKSTYLE_ON: LineLength
+// CHECKSTYLE_ON: LineLength
 public class WarMojo
     extends AbstractWarMojo
 {
@@ -139,7 +139,6 @@ public class WarMojo
      *   <classifier>classes</classifier>
      * </dependency>]]>
      * </pre>
-     * 
      * </p>
      *
      * @since 2.1-alpha-2
@@ -155,6 +154,15 @@ public class WarMojo
     @Parameter( defaultValue = "classes" )
     private String classesClassifier = "classes";
 
+    /**
+     * You can skip the execution of the plugin if you need to. Its use is NOT RECOMMENDED, but quite convenient on
+     * occasion.
+     * 
+     * @since 3.0.0
+     */
+    @Parameter( property = "maven.war.skip", defaultValue = "false" )
+    private boolean skip;
+
     // ----------------------------------------------------------------------
     // Implementation
     // ----------------------------------------------------------------------
@@ -168,6 +176,13 @@ public class WarMojo
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
+
+        if ( isSkip() )
+        {
+            getLog().info( "Skipping the execution." );
+            return;
+        }
+
         File warFile = getTargetWarFile();
 
         try
@@ -218,7 +233,8 @@ public class WarMojo
         archiver.setOutputFile( warFile );
 
         // CHECKSTYLE_OFF: LineLength
-        getLog().debug( "Excluding " + Arrays.asList( getPackagingExcludes() ) + " from the generated webapp archive." );
+        getLog().debug( "Excluding " + Arrays.asList( getPackagingExcludes() )
+            + " from the generated webapp archive." );
         getLog().debug( "Including " + Arrays.asList( getPackagingIncludes() ) + " in the generated webapp archive." );
         // CHECKSTYLE_ON: LineLength
 
@@ -514,4 +530,9 @@ public class WarMojo
     {
         this.failOnMissingWebXml = failOnMissingWebXml;
     }
+
+    public boolean isSkip()
+    {
+        return skip;
+    }
 }