1

Within my pom.xml I define following plugins - maven-shade, maven-compiler and maven-failsafe:

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <id>shade-main</id>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <outputFile>target/assembly/${project.artifactId}.jar</outputFile>
                        <filters>
                            <filter>
                                <artifact>*:*</artifact>
                                <excludes>
                                    <exclude>META-INF/*.SF</exclude>
                                    <exclude>META-INF/*.DSA</exclude>
                                    <exclude>META-INF/*.RSA</exclude>
                                </excludes>
                            </filter>
                        </filters>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.handlers</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.schemas</resource>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <executions>
                <execution>
                    <id>default-compile</id>
                    <phase>none</phase>
                </execution>
                <execution>
                    <id>default-testCompile</id>
                    <phase>none</phase>
                </execution>
                <execution>
                    <id>java-compile</id>
                    <phase>compile</phase>
                    <goals> <goal>compile</goal> </goals>
                </execution>
                <execution>
                    <id>java-test-compile</id>
                    <phase>test-compile</phase>
                    <goals> <goal>testCompile</goal> </goals>
                </execution>
            </executions>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>${project.build.sourceEncoding}</encoding>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.20.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        ...
    </plugins>
</build>

When I run mvn package it nicely compiles the project and builds a jar with shade-plugin. However when I run mvn verify the shade-plugin should not be run, but it does and it takes unnecessary time before the tests are executed.

How can I prevent the shade plugin to run on mvn verify?

EDIT:

After some comments I want to clarify I still need to do the package phase, I just want to skip the execution of shade plugin.

Vojtěch
  • 11,312
  • 31
  • 103
  • 173
  • You can not. See the LifeCycle of maven. Also what will you verify if you do not build the artefact before? – Jens Feb 07 '18 at 08:40
  • Ok, I see. Can I somehow run the integration tests without packaging? – Vojtěch Feb 07 '18 at 08:44
  • 1
    See https://stackoverflow.com/questions/6612344/prevent-unit-tests-in-maven-but-allow-integration-tests But for me it makes no sence Integration test without building the application – Jens Feb 07 '18 at 08:46
  • 1
    I use shade plugin only to generate the final JAR, but for integration tests it is not needed and just take too much time. – Vojtěch Feb 07 '18 at 08:50

0 Answers0