Maven dependency Plugin: Difference between revisions
(Created page with "=Internal= * Maven") |
|||
(16 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=External= | |||
* http://maven.apache.org/plugins/maven-dependency-plugin/ | |||
=Internal= | =Internal= | ||
* [[Maven#Plugin|Maven]] | * [[Maven#Plugin|Maven]] | ||
=Operations= | |||
==List== | |||
<pre> | |||
mvn dependency:resolve | |||
</pre> | |||
==Tree== | |||
{{External|https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html}} | |||
mvn dependency:tree [-Dverbose=true] | |||
To find out where artifacts belonging to a specific group are used, employ the following syntax: | |||
mvn dependency:tree -Dincludes=<groupId> | |||
mvn -s config/maven3/settings.xml dependency:tree -Dincludes=commons-beanutils | |||
Finer granularity is possible, see [https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html Filtering the dependency tree]. | |||
==Build Classpath== | |||
This is a goal that can be used to build a complete dependency classpath (less the artifact itself), as required by the Maven project artifact to function. The classpath is generated in the format to be used in java -cp. It proved useful in wrapper scripts, where it eliminates the need to manually specify the classpath. | |||
Note that the artifact itself is not present on the classpath. If needed, it has to be added independently. | |||
<pre> | |||
mvn dependency:build-classpath | |||
</pre> | |||
More details: {{External|http://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-mojo.html}} | |||
==Analyze== | |||
Optimize dependencies with | |||
<pre> | |||
mvn dependency:analyze | |||
</pre> | |||
=Include Dependencies - or Some of the Dependencies - in JAR= | |||
There are situations when we want to extract some of the dependencies and bundle them with the JAR artifact. This is done using the jar plugin and the dependency plugin together, as described here: | |||
{{Internal|Maven Include Dependencies in JAR Artifact|Include Dependencies in JAR Artifact}} | |||
=Download Sources with the Class JAR Files= | |||
{{Internal|Maven Download Sources with the Class JAR Files|Download Sources with the Class JAR Files}} | |||
=Cache Locally an Artifact Pulled from a Remote Repository= | |||
<syntaxhighlight lang='bash'> | |||
mvn dependency:get -DrepoUrl=<url> -Dartifact=<groupId>:<artifactId>:<version> | |||
mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=<url> -Dartifact=<groupId>:<artifactId>:<version> | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
mvn dependency:get -DrepoUrl=https://repo.maven.apache.org/maven2 -Dartifact=org.apache.logging.log4j:log4j-slf4j-impl:2.12.1 | |||
</syntaxhighlight> |
Latest revision as of 20:23, 1 September 2020
External
Internal
Operations
List
mvn dependency:resolve
Tree
mvn dependency:tree [-Dverbose=true]
To find out where artifacts belonging to a specific group are used, employ the following syntax:
mvn dependency:tree -Dincludes=<groupId>
mvn -s config/maven3/settings.xml dependency:tree -Dincludes=commons-beanutils
Finer granularity is possible, see Filtering the dependency tree.
Build Classpath
This is a goal that can be used to build a complete dependency classpath (less the artifact itself), as required by the Maven project artifact to function. The classpath is generated in the format to be used in java -cp. It proved useful in wrapper scripts, where it eliminates the need to manually specify the classpath.
Note that the artifact itself is not present on the classpath. If needed, it has to be added independently.
mvn dependency:build-classpath
More details:
Analyze
Optimize dependencies with
mvn dependency:analyze
Include Dependencies - or Some of the Dependencies - in JAR
There are situations when we want to extract some of the dependencies and bundle them with the JAR artifact. This is done using the jar plugin and the dependency plugin together, as described here:
Download Sources with the Class JAR Files
Cache Locally an Artifact Pulled from a Remote Repository
mvn dependency:get -DrepoUrl=<url> -Dartifact=<groupId>:<artifactId>:<version>
mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=<url> -Dartifact=<groupId>:<artifactId>:<version>
mvn dependency:get -DrepoUrl=https://repo.maven.apache.org/maven2 -Dartifact=org.apache.logging.log4j:log4j-slf4j-impl:2.12.1