I have a local jar and I want to use it in my project. There are plenty ways to do it: just install manually into local repo, do it with script in parent pom, use system scope, use local repo declaration.
I decided to use Maven Install plugin to install jar into the repo. Here is a configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>jacob</groupId>
<artifactId>jacob</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<file>${basedir}\lib\jacob.jar</file>
</configuration>
</execution>
</executions>
</plugin>
I tried to run it in many ways: mvn initialize install:install-file mvn initialize mvn install:install-file
But all the time I have an exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file (default-cli) on project MYPROJECTNAME: The parameters 'file' for goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file are missing or invalid ->
I just want to find out why it doesn't work? Looks like I am messed with phases and goals..
Finally I went another way: I placed it into my parent POM, but why it works with parent and doesn't work with child?
For this reason, future Maven versions might no longer support building such malformed projects. org.apache.maven.plugins:maven.compiler. The plugin is a plugin that can be added by “Add Denpendency”.
That is the reason why you got the described error message, cause the command line part needs required parameters which you didn't gave on command line. Make in Maven no sense (rarly).
Maven uses two terms to refer to this datum: the <packaging> element for the entire POM, and the <type> element in a dependency specification. User property is: packaging. Location of an existing POM file to be deployed alongside the main artifact, given by the $ {file} parameter. User property is: pomFile.
Since you have bound install:install-filegoal to the generate-sourcesphase, you should run mvn compileor mvn installor such to use the defined configurations. mvn eclipse:eclipseworks because maven runs the generate-sourcesphase prior to invoking eclipse:eclipse.
The best way to deal with a separated jar is to start using a repository manager and install this jar via the UI into the repository manager. From that point you can use as a usual dependency. Makes life easier.
If you like to install it as part of the build what you have tried that means you need to call maven like this:
mvn package
You should not mix up calling goals without life cylce like install:install-file
with life-cycle parts as initialize
.
That is the reason why you got the described error message, cause the command line part needs required parameters which you didn't gave on command line.
Combination like:
mvn install:install-file initialize
Make in Maven no sense (rarly). You have bound the maven-install-plugin to the life-clycle in your pom so you should simply call the life cylce:
mvn initalize
And you will get something like the following:
[INFO] ------------------------------------------------------------------------
[INFO] Building test 0.6-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default) @ test ---
[INFO] Installing /home/mvntest/lib/jdom-1.0.jar to /home/.m2/repository/com/soebes/test/jacob/1.1/jacob-1.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.780s
[INFO] Finished at: Sat Oct 25 12:19:30 CEST 2014
[INFO] Final Memory: 6M/91M
[INFO] ------------------------------------------------------------------------
BUT: I have to say that installing an artifact like you did is bad practice. Best is to use a repository manager like Nexus, Artifactory or Archiva or if really don't like repository managers (I don't understand why, but this is a different story) you can use Stephen Connolly's non-maven-jar-maven-plugin
Apart from all the above you should use more up-to-date versions of maven-install-plugin which current version number is 2.5.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With