Reputation: 173
I have the following Maven project structure:
sub-projectB
<- jarsub-projectC
<- warsub-projectD
<- warsub-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?
Upvotes: 1
Views: 336
Reputation: 137259
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>
Upvotes: 3