Exclude packages while generating sources jar in Maven

jam

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

Tunaki

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>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Generating jar of a maven project with all sources

From Dev

Maven Error while generating sources for Hadoop

From Dev

Maven assembly or shade plugin - How to exclude sources from jar?

From Dev

How can I exclude some packages (within a JAR) from a Maven dependency?

From Dev

maven-jaxb2-plugin not generating sources

From Dev

How to Exclude Certain Jar Dependencies while creating jar without using maven?

From Dev

maven: exclude jar from JDK

From Dev

Maven Create Jar and exclude Files

From Dev

Cannot download sources from jar in intellij with maven

From Dev

JOOQ : Generate sources with maven in Eclipse is not generating any file

From Dev

maven-dependency-plugin: exclude .jar files

From Dev

How to exclude a package from a jar (with maven)

From Dev

Maven - How to exclude dependencies from generated JAR

From Dev

how to create jar for specific packages maven

From Dev

Android Studio fails to read packages while generating JavaDoc

From Dev

Android Studio fails to read packages while generating JavaDoc

From Dev

How to download sources for an specific JAR dependency of a Maven project

From Dev

maven: create a jar from generated sources and add it as a dependency before compiling

From Dev

What is making the *sources.jar during Maven release?

From Dev

How do I attach scala sources to my maven jar?

From Java

Maven Jacoco Configuration - Exclude classes/packages from report not working

From Dev

protoc-jar-maven-plugin: Not generating grpc service stubs

From Dev

Exclude META-INF/maven folder from the generated jar file

From Dev

How to use maven assembly plugin to exclude a package from dependency jar?

From Dev

Maven: How to have jar-with-dependencies exclude "provided" dependencies?

From Dev

Maven site lifecycle failing while generating allure report

From Dev

Why is Maven's documentation packages in a JAR instead of a ZIP file?

From Dev

How do I exclude java files from a jar in maven-jar-plugin?

From Dev

How to exclude all shades of gray while generating random hex color code?

Related Related

  1. 1

    Generating jar of a maven project with all sources

  2. 2

    Maven Error while generating sources for Hadoop

  3. 3

    Maven assembly or shade plugin - How to exclude sources from jar?

  4. 4

    How can I exclude some packages (within a JAR) from a Maven dependency?

  5. 5

    maven-jaxb2-plugin not generating sources

  6. 6

    How to Exclude Certain Jar Dependencies while creating jar without using maven?

  7. 7

    maven: exclude jar from JDK

  8. 8

    Maven Create Jar and exclude Files

  9. 9

    Cannot download sources from jar in intellij with maven

  10. 10

    JOOQ : Generate sources with maven in Eclipse is not generating any file

  11. 11

    maven-dependency-plugin: exclude .jar files

  12. 12

    How to exclude a package from a jar (with maven)

  13. 13

    Maven - How to exclude dependencies from generated JAR

  14. 14

    how to create jar for specific packages maven

  15. 15

    Android Studio fails to read packages while generating JavaDoc

  16. 16

    Android Studio fails to read packages while generating JavaDoc

  17. 17

    How to download sources for an specific JAR dependency of a Maven project

  18. 18

    maven: create a jar from generated sources and add it as a dependency before compiling

  19. 19

    What is making the *sources.jar during Maven release?

  20. 20

    How do I attach scala sources to my maven jar?

  21. 21

    Maven Jacoco Configuration - Exclude classes/packages from report not working

  22. 22

    protoc-jar-maven-plugin: Not generating grpc service stubs

  23. 23

    Exclude META-INF/maven folder from the generated jar file

  24. 24

    How to use maven assembly plugin to exclude a package from dependency jar?

  25. 25

    Maven: How to have jar-with-dependencies exclude "provided" dependencies?

  26. 26

    Maven site lifecycle failing while generating allure report

  27. 27

    Why is Maven's documentation packages in a JAR instead of a ZIP file?

  28. 28

    How do I exclude java files from a jar in maven-jar-plugin?

  29. 29

    How to exclude all shades of gray while generating random hex color code?

HotTag

Archive