Skip to content

Commit

Permalink
[MSHADE-382] Add property to skip execution
Browse files Browse the repository at this point in the history
* added a skip field to ShadeMojo

Co-authored-by: Markus Karg <markus@headcrashing.eu>
  • Loading branch information
2 people authored and Tibor17 committed Jul 19, 2021
1 parent 24d5d42 commit cf2d90c
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 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+
55 changes: 55 additions & 0 deletions 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>
20 changes: 20 additions & 0 deletions 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."
12 changes: 12 additions & 0 deletions src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
Expand Up @@ -385,12 +385,24 @@ public class ShadeMojo
@Inject
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();

Expand Down

0 comments on commit cf2d90c

Please sign in to comment.