Issue
I have a local jar (a maven plugin I wrote myself) which I am installing with
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=dependencies/my-maven-plugin-1.0.jar
The plugin has some dependencies (defined in the pom.xml within the jar);
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>com.hubspot.jinjava</groupId>
<artifactId>jinjava</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
But using the maven-install-plugin, these are not installed. Can I somehow install the needed dependencies automatically when installing the jar?
Solution
No, you can't do that. And it is normal: the maven-install-plugin
will install the file you pass it, which in this case is my-maven-plugin-1.0.jar
, and that's it. It will also look inside the JAR to find a POM to install as well, because without a POM installed, the installed artifact won't be usable as a dependency.
But it doesn't do it, because it isn't needed. Next time you depend on this artifact, with the coordinates written in the POM, Maven will automatically download the dependencies from your configured remote repositories (Maven Central by default) and install them in the local repository. There won't be the need to manually launch the install-file
goal; this is only useful when the artifact isn't available on Maven repositories.
If the maven-install-plugin
would also install the dependencies of the artifact to manually install, it would just do the same thing Maven itself would do when you finally depend on that artifact in one of your projects.
Answered By - Tunaki
Answer Checked By - Mildred Charles (JavaFixing Admin)