[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.


git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1718188 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/it/skip-yes/pom.xml b/src/it/skip-yes/pom.xml
new file mode 100644
index 0000000..5f4677d
--- /dev/null
+++ b/src/it/skip-yes/pom.xml
@@ -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>
diff --git a/src/it/skip-yes/src/main/resources/test-resource.txt b/src/it/skip-yes/src/main/resources/test-resource.txt
new file mode 100644
index 0000000..b4c4213
--- /dev/null
+++ b/src/it/skip-yes/src/main/resources/test-resource.txt
@@ -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
diff --git a/src/it/skip-yes/verify.groovy b/src/it/skip-yes/verify.groovy
new file mode 100644
index 0000000..d35f5e3
--- /dev/null
+++ b/src/it/skip-yes/verify.groovy
@@ -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;
diff --git a/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java b/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java
index 4e04c62..c57e672 100644
--- a/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java
+++ b/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java
@@ -241,6 +241,14 @@
     @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 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 @@
         this.useDefaultDelimiters = useDefaultDelimiters;
     }
 
+    public boolean isSkip()
+    {
+        return skip;
+    }
+
 }