I ran across the use case described in the title when working with a legacy web application which also serves as a dependency for other (plugin) projects. To this end, besides the War file which is deployed as web application, I would like to have the contained Jar file being installed separately in my local repository.
This additional artifact can be obtained with a few lines in the pom.xml:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <version>2.4</version> <executions> <execution> <phase>install</phase> <goals> <goal>install-file</goal> </goals> <configuration> <packaging>jar</packaging> <artifactId>${project.artifactId}</artifactId> <groupId>${project.groupId}</groupId> <version>${project.version}</version> <file> ${project.build.directory}/${project.build.finalName}/WEB-INF/lib/${project.artifactId}-${project.version}.jar </file> </configuration> </execution> </executions> </plugin>
This execution extracts the Jar file which is produced during the preparations of the War file and installs it with the project’s default group id, artifact id, and version.
Links
- [1] Maven Install Plugin: install-file