[ 
https://issues.apache.org/jira/browse/MSHADE-382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17324073#comment-17324073
 ] 

Andres Almiray commented on MSHADE-382:
---------------------------------------

The POM is generated using [https://micronaut.io/launch/] and looks like this
{code:java}
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd";>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>demo</artifactId>
  <version>0.1</version>
  <packaging>${packaging}</packaging>  <parent>
    <groupId>io.micronaut</groupId>
    <artifactId>micronaut-parent</artifactId>
    <version>2.4.2</version>
  </parent>  <properties>
    <packaging>jar</packaging>
    <jdk.version>11</jdk.version>
    <release.version>11</release.version>
    <micronaut.version>2.4.2</micronaut.version>
    <exec.mainClass>com.example.Application</exec.mainClass>
    <micronaut.runtime>netty</micronaut.runtime>
  </properties>  <repositories>
    <repository>
      <id>central</id>
      <url>https://repo.maven.apache.org/maven2</url>
    </repository>
  </repositories>  <dependencies>
    <dependency>
      <groupId>io.micronaut</groupId>
      <artifactId>micronaut-inject</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.micronaut</groupId>
      <artifactId>micronaut-validation</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.micronaut</groupId>
      <artifactId>micronaut-http-server-netty</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.micronaut.test</groupId>
      <artifactId>micronaut-test-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.micronaut</groupId>
      <artifactId>micronaut-http-client</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.micronaut</groupId>
      <artifactId>micronaut-runtime</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <scope>compile</scope>
    </dependency>
  </dependencies>  <build>
    <plugins>
      <plugin>
        <groupId>io.micronaut.build</groupId>
        <artifactId>micronaut-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <!-- Uncomment to enable incremental compilation -->
          <!-- <useIncrementalCompilation>false</useIncrementalCompilation> --> 
         <annotationProcessorPaths combine.children="append">
          </annotationProcessorPaths>
          <compilerArgs>
            <arg>-Amicronaut.processing.group=com.example</arg>
            <arg>-Amicronaut.processing.module=demo</arg>
          </compilerArgs>
        </configuration>
      </plugin>
    </plugins>
  </build></project>

{code}
You'll notice that the shade plugin does not appear on it, and as you mentioned 
it's managed in the parent. The micronaut-maven-plugin provides its own 
lifecycle

[https://github.com/micronaut-projects/micronaut-maven-plugin/blob/a62b17d1c9fbf34c5a653fd374ff7087a1b0e65f/src/main/resources/META-INF/plexus/components.xml]

Which activates the shade plugin during the `package` phase.

Now, my use case requires a plain modular JAR with no shaded dependencies. My 
workaround was to alter the shade configuration so that the shaded JAR does not 
overwrite the original JAR
{code:java}
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>${maven-shade-plugin.version}</version>
        <executions>
          <execution>
            <id>default-shade</id>
            <configuration>
              <shadedArtifactAttached>true</shadedArtifactAttached>
              <shadedClassifierName>all</shadedClassifierName>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <transformers>
                <transformer 
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>${exec.mainClass}</mainClass>
                </transformer>
                <transformer 
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
{code}
It would be much better for me if I could simply skip shading completely. 
Clearly the Micronaut team believes that offering an opinionated build 
out-of-the-box is what will give the best possible experience to those 
developers that may not be so familiar with the Maven lifecycle, after all they 
just have to configure one plugin (micronaut-maven-plugin) and 1 parent 
(micronaut-parent) and they get lots of behavior "for free".

 

> Add an option to skip execution
> -------------------------------
>
>                 Key: MSHADE-382
>                 URL: https://issues.apache.org/jira/browse/MSHADE-382
>             Project: Maven Shade Plugin
>          Issue Type: Improvement
>    Affects Versions: 3.2.4
>            Reporter: Andres Almiray
>            Priority: Major
>
> It'd be great to have a property for skipping execution, such as 
> `maven.shade.skip`. Useful when a parent has setup shading but a child would 
> like to skip it for example.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to