Embracing the Messiness in Search of Epic Solutions

Maven JAR Plugin: Excluding Package(s) from JAR

Posted

in

Let’s assume we want to exclude com.choonchernlim.epicapp.scratch package when we create the JAR file.

Add the following in pom.xml:-

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <id>default-jar</id>
            <phase>package</phase>
            <goals>
                <goal>jar</goal>
            </goals>
            <configuration>
                <excludes>
                    <exclude>**/scratch/**</exclude>
                </excludes>
            </configuration>
        </execution>
    </executions>
</plugin>

The key here is to specify the execution ID called default-jar.

Comments

Leave a Reply