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 2015/12/06 16:42:39 UTC

svn commit: r1718188 - in /maven/plugins/trunk/maven-resources-plugin/src: it/skip-yes/ it/skip-yes/src/ it/skip-yes/src/main/ it/skip-yes/src/main/resources/ main/java/org/apache/maven/plugin/resources/

Author: khmarbaise
Date: Sun Dec  6 15:42:39 2015
New Revision: 1718188

URL: http://svn.apache.org/viewvc?rev=1718188&view=rev
Log:
[MRESOURCES-203] Add a skip option to skip the execution of resources goal
Added the skip option for resources goal as well as an integration test.

Added:
    maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/
    maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/pom.xml
    maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/src/
    maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/src/main/
    maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/src/main/resources/
    maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/src/main/resources/test-resource.txt
    maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/verify.groovy
Modified:
    maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java

Added: maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/pom.xml?rev=1718188&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/pom.xml (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/pom.xml Sun Dec  6 15:42:39 2015
@@ -0,0 +1,48 @@
+<?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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins</groupId>
+  <artifactId>maven-resources-plugin-it-skip-yes</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>@project.version@</version>
+          <configuration>
+            <skip>true</skip>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/src/main/resources/test-resource.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/src/main/resources/test-resource.txt?rev=1718188&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/src/main/resources/test-resource.txt (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/src/main/resources/test-resource.txt Sun Dec  6 15:42:39 2015
@@ -0,0 +1,17 @@
+# 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.
+test

Added: maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/verify.groovy?rev=1718188&view=auto
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/verify.groovy (added)
+++ maven/plugins/trunk/maven-resources-plugin/src/it/skip-yes/verify.groovy Sun Dec  6 15:42:39 2015
@@ -0,0 +1,22 @@
+/*
+ * 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 buildLogFile = new File( basedir, "build.log");
+
+assert buildLogFile.text.contains("Skipping the execution.")
+return true;

Modified: maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java?rev=1718188&r1=1718187&r2=1718188&view=diff
==============================================================================
--- maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java (original)
+++ maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java Sun Dec  6 15:42:39 2015
@@ -241,6 +241,14 @@ public class ResourcesMojo
     @Parameter( defaultValue = "false" )
     private boolean fileNameFiltering;
 
+    /**
+     * 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.resources.skip", defaultValue = "false" )
+    private boolean skip;
+
     public void contextualize( Context context )
         throws ContextException
     {
@@ -250,13 +258,19 @@ public class ResourcesMojo
     public void execute()
         throws MojoExecutionException
     {
+        if ( isSkip() )
+        {
+            getLog().info( "Skipping the execution." );
+            return;
+        }
+
         try
         {
 
             if ( StringUtils.isEmpty( encoding ) && isFilteringEnabled( getResources() ) )
             {
                 getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
-                                   + ", i.e. build is platform dependent!" );
+                    + ", i.e. build is platform dependent!" );
             }
 
             List<String> filters = getCombinedFiltersList();
@@ -467,4 +481,9 @@ public class ResourcesMojo
         this.useDefaultDelimiters = useDefaultDelimiters;
     }
 
+    public boolean isSkip()
+    {
+        return skip;
+    }
+
 }