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

4

1 回答 1

2

您可以maven-source-plugin使用以下excludes属性配置:

要排除的文件列表。指定为文件集模式,这些模式与将其内容打包到 JAR 中的输入目录相关。

您将排除包下的每个类的示例配置com.my.package如下:

<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>
于 2016-03-09T16:42:55.107 回答