2

I would like to generate a sources jar but without some packages in my project.

Now I have this in my pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
                <execution>
                    <id>sources</id>
                    <goals>
                        <goal>jar</goal>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

How to exclude specific packages?

similar but with netbeans environment

Community
  • 1
  • 1
jam
  • 1,253
  • 1
  • 12
  • 26

1 Answers1

2

You can configure the maven-source-plugin with the excludes attribute:

List of files to exclude. Specified as fileset patterns which are relative to the input directory whose contents is being packaged into the JAR.

A sample configuration where you would exclude every class under the package com.my.package would be the following:

<plugin>
    <artifactId>maven-source-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>sources</id>
            <goals>
                <goal>jar</goal>
                <goal>test-jar</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <excludes>
                    <exclude>com/my/package/**</exclude>
                </excludes>
            </configuration>
        </execution>
    </executions>
</plugin>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • it's not excluding the packages I define; is it a problem to define the package like com.my.package/** – jam Mar 09 '16 at 17:15
  • 1
    @jam Yes it is a problem, you need to use the slashes as they refer to the files on disk. – Tunaki Mar 09 '16 at 17:17