Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Maven 'system' scope transitive, but 'provided' not?

Tags:

maven

Maven's POM reference states the following:

provided - this is much like compile, but indicates you expect the JDK or a container to provide it at runtime. It is only available on the compilation and test classpath, and is not transitive.

...

system - this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.

I have now converted a project with a lot of 'system' dependencies to 'provided'. However, it appears that system dependencies are transitive, which makes them very un-similar to provided, and is now causing many missing dependencies in my build. My question is twofold:

  1. Is system scope transitive? If so, is the Maven reference wrong or incomplete?
  2. Is there a way to make dependencies transitive, without packaging them into the final assembly?
like image 528
Andre van der Schyff Avatar asked Feb 11 '11 13:02

Andre van der Schyff


1 Answers

Transitive dependencies will always be part of the assembly. There is no scope to state your intentioned behaviour.

The question is: Why has a project that is intended to be included in other projects (as you stated with the intention to have transitive dependencies) an assembly? Typically a project that has an WAR-assembly will not be included as dependency in other projects (WAR-dependencies do not provide their transitive dependencies at all because they are only intended for WAR overlays).

If this is a maven assembly this is simple. The Maven Assembly plugin has "excludes" to filter the files that have to be copied.

If this would be a WAR-Project you could exclude some JARs from the WAR with these excludes:

<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
      <packagingExcludes>WEB-INF/lib/*-[toExclude1]-*.jar,WEB-INF/lib/[toExclude2]*.jar</packagingExcludes>
  </configuration>
</plugin>
like image 144
Marc von Renteln Avatar answered Oct 23 '22 16:10

Marc von Renteln