maven - how to exclude an entire module on from war

vkumars

I have the following Maven project structure:

  • ProjectA
    • sub-projectB <- jar
    • sub-projectC <- war
    • sub-projectD <- war

sub-projectC and sub-projectD need to have sub-projectB as a dependency. But the war built by sub-projectC and sub-projectD should not include the dependencies of sub-projectB. The jar will be included separately later in the classpath (this is because sub-projectB is large jar >100MB and packaging it with the war will be very expensive both in terms of size and time it takes to copy the war from one location to another during deployment).

How do I exclude the dependencies of sub-projectB from the war package of sub-projectC and sub-projectD?

One way to do it is to exclude the list of jars in the maven-war-plugin. But we have to specify each and every jar names or use wild-card. We can not exclude a sub-module dependencies directly. Is there an easier way to do it?

Tunaki

This is exactly what the scope provided is for. Each dependency with this scope will be used at compile-time but it will not be included in the final war (because it is provided by the run-time container).

As such, the dependency to sub-projectB should be, in sub-projectC and sub-projectD pom:

<dependency>
    <groupId>...</groupId>
    <artifactId>sub-projectB</artifactId>
    <version>...</version>
    <scope>provided</scope>
</dependency>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Maven - Exclude class files from war

From Dev

How to exclude certain resources from the maven war plugin war file?

From Dev

Copy war dependency mentioned in maven jar module

From Dev

How to exclude some maven project from sonar analysis

From Dev

Conditionally exclude some resources in maven from war

From Dev

Filtering in maven-war-plugin does not exclude directory

From Dev

OpenEJB: How to exclude jar from module search?

From Dev

Maven -pl !<module> doesn't exclude submodules of <module> from the build

From Dev

How to exclude a maven test scope from package phase?

From Dev

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

From Dev

how to exclude nested node_module folders from a loader in webpack

From Dev

How do I setup arquillian to test a maven war project by deploying the entire war to WildFly embedded?

From Dev

How to exclude a single module from Javadoc generation in a Maven multi module project?

From Dev

SonarQube exclude Maven module

From Dev

How to exclude jasperreports artifact from jasperreports maven plugin

From Dev

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

From Dev

How to exclude an entire directory from Android 6 Auto Backup?

From Dev

How to exclude module-info.java from checkstyle plugin checks?

From Dev

How to exclude project dependency from classpath used by maven plugin

From Dev

Maven - Exclude class files from war

From Dev

exclude WEB-INF from a maven generated war

From Dev

How Exclude Plugin from integration-test in Eclipse RCP / Maven

From Dev

SonarQube exclude Maven module

From Dev

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

From Dev

Maven war plugin archiveClasses but exclude a package

From Dev

Scalatest from Maven: How to tag and filter out an entire Suite?

From Dev

How to exclude persistence.xml from maven resolver

From Dev

How to exclude package from scoverage in maven

From Dev

Maven - How to exclude dependencies from generated JAR

Related Related

  1. 1

    Maven - Exclude class files from war

  2. 2

    How to exclude certain resources from the maven war plugin war file?

  3. 3

    Copy war dependency mentioned in maven jar module

  4. 4

    How to exclude some maven project from sonar analysis

  5. 5

    Conditionally exclude some resources in maven from war

  6. 6

    Filtering in maven-war-plugin does not exclude directory

  7. 7

    OpenEJB: How to exclude jar from module search?

  8. 8

    Maven -pl !<module> doesn't exclude submodules of <module> from the build

  9. 9

    How to exclude a maven test scope from package phase?

  10. 10

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

  11. 11

    how to exclude nested node_module folders from a loader in webpack

  12. 12

    How do I setup arquillian to test a maven war project by deploying the entire war to WildFly embedded?

  13. 13

    How to exclude a single module from Javadoc generation in a Maven multi module project?

  14. 14

    SonarQube exclude Maven module

  15. 15

    How to exclude jasperreports artifact from jasperreports maven plugin

  16. 16

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

  17. 17

    How to exclude an entire directory from Android 6 Auto Backup?

  18. 18

    How to exclude module-info.java from checkstyle plugin checks?

  19. 19

    How to exclude project dependency from classpath used by maven plugin

  20. 20

    Maven - Exclude class files from war

  21. 21

    exclude WEB-INF from a maven generated war

  22. 22

    How Exclude Plugin from integration-test in Eclipse RCP / Maven

  23. 23

    SonarQube exclude Maven module

  24. 24

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

  25. 25

    Maven war plugin archiveClasses but exclude a package

  26. 26

    Scalatest from Maven: How to tag and filter out an entire Suite?

  27. 27

    How to exclude persistence.xml from maven resolver

  28. 28

    How to exclude package from scoverage in maven

  29. 29

    Maven - How to exclude dependencies from generated JAR

HotTag

Archive