Talking about Maven, I know that:
For example, in the case of a compile scoped dependency in a jar packaging, at compile time Maven will simply fetch the dependency from local/remote repositories, without including such dependency in the final artifact.
If all this is correct, my questions are:
1) Who is then usually providing a compile scoped dependency at runtime for a jar artifact?
2) What is the difference between a provided dependency in a jar and a war packaging then?
1) Who is then usually providing a compile scoped dependency at runtime for a jar artifact?
If you integrate the Maven assembly plugin to your pom.xml
, the dependencies with scope compile
will be packed to the assembly, together with your projects artifact. The dependencies with scope provided
are not added:
Here is an example. It assumes that there is an specific assembly descriptor (projectAssembly.xml
), not a default one.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>${artifactId}-${version}-distribution</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/projectAssembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
2) What is the difference between a provided dependency in a jar and a war packaging then?
In both cases, the dependencies aren't added.