Reputation: 5224
I'm currently using:
mvn install:install-file -Dfile={path/to/my/legacy.jar} -DgroupId=horrible -DartifactId=legacy.jar -Dversion=1.2.3 -Dpackaging=jar
to import some old legacy jars into my repo. This has worked fine and is the recommended approach. It seems as though this could be done with a POM instead of at the commandline + script that I'm using now. I think it's cleaner to have:
mvn install:install-file
and let my repo store the version details rather than store this information in a non-maven script (which is odd for maven). I tried to expose these -D settings via the settings tag but that didn't work. Has any one else tried this and got it to work?
Upvotes: 27
Views: 21272
Reputation: 5224
Okay, answering my own question :P. You can do this by defining properties, I originally assumed the groupId etc were auto exported as properties but they are not.
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.whatever</groupId>
<artifactId>Stuff</artifactId>
<version>1.2.3</version>
<description>
Description of why this horrible jar exists.
</description>
<properties>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>${project.packaging}</packaging>
<file>mylegacy.jar</file>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
You can now install files using:
mvn install
and this pom.xml. I have tested this with maven 3 and not 2.
For multiple files also see Maven POM file for installing multiple 3rd party commercial libraries
Upvotes: 38