Enforce Clean before shade

It’s a bad idea, but if you have to use Maven Shade plugin in order to include classes from your dependencies to your artifact and especially if you invoke shade more than one during the buildĀ , the results become more predictable if you force invocation of “clean” command. You can do it by adding the following snippet to pom.xml

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>auto-clean</id>
            <phase>initialize</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
 </build>
 [...]
</project>

Keep your shades clean

Leave a Reply

Your email address will not be published. Required fields are marked *

Please, enter correct number below to prevent spam (required)