10
votes

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?
1
What do you mean by "make dependencies transitive"? (As for system scope, its justification is "system dependencies are especially useful for resolving dependencies on artifacts which are now provided by the JDK, but where available as separate downloads earlier" ... that makes absolutely no sense to me, since you need to change the POM once it's provided by the JDK anyway, so might as well change the scope to provided.) - Emerson Farrugia
system scope is similar to provided in that it is stating that the dependency will be provided by something other than Maven. - Stephen Connolly

1 Answers

2
votes

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>