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 00000000..c8b7b3cd --- /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 00000000..765780e0 --- /dev/null +++ b/src/it/projects/MSHADE-382_skip_execution/pom.xml @@ -0,0 +1,55 @@ + + + + + + 4.0.0 + + org.apache.maven.its.shade.mj + skip-execution + 1.0 + + MSHADE-382 + + Skip shading + + + + + + org.apache.maven.plugins + maven-shade-plugin + @project.version@ + + + create-shaded-artifact + package + + shade + + + true + + + + + + + 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 00000000..377c5f39 --- /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 7c524f80..6cc019cd 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 @@ -385,12 +385,24 @@ public class ShadeMojo @Inject private Map 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();