[MSHADE-382] Add property to skip execution
* added a skip field to ShadeMojo
Co-authored-by: Markus Karg <markus@headcrashing.eu>
diff --git a/src/it/projects/MSHADE-382_skip_execution/invoker.properties b/src/it/projects/MSHADE-382_skip_execution/invoker.properties
new file mode 100644
index 0000000..c8b7b3c
--- /dev/null
+++ b/src/it/projects/MSHADE-382_skip_execution/invoker.properties
@@ -0,0 +1,18 @@
+# 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.java.version = 1.8+
diff --git a/src/it/projects/MSHADE-382_skip_execution/pom.xml b/src/it/projects/MSHADE-382_skip_execution/pom.xml
new file mode 100644
index 0000000..765780e
--- /dev/null
+++ b/src/it/projects/MSHADE-382_skip_execution/pom.xml
@@ -0,0 +1,55 @@
+<?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.shade.mj</groupId>
+ <artifactId>skip-execution</artifactId>
+ <version>1.0</version>
+
+ <name>MSHADE-382</name>
+ <description>
+ Skip shading
+ </description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>create-shaded-artifact</id>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/projects/MSHADE-382_skip_execution/verify.groovy b/src/it/projects/MSHADE-382_skip_execution/verify.groovy
new file mode 100644
index 0000000..377c5f3
--- /dev/null
+++ b/src/it/projects/MSHADE-382_skip_execution/verify.groovy
@@ -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.
+ */
+
+assert !(new File( basedir, "target/original-skip-execution-1.0.jar" ).exists()) : "Shading was not skipped."
\ No newline at end of file
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
index 7c524f8..6cc019c 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
@@ -386,11 +386,23 @@
private Map<String, Shader> shaders;
/**
+ * When true, skips the execution of this MOJO.
+ * @since 3.3.0
+ */
+ @Parameter( defaultValue = "false" )
+ private boolean skip;
+
+ /**
* @throws MojoExecutionException in case of an error.
*/
public void execute()
throws MojoExecutionException
{
+ if ( skip )
+ {
+ getLog().info( "Shading has been skipped." );
+ return;
+ }
setupHintedShader();