4

I ran the following command to install a custom jar in my local repository:

mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file -Dfile=<path-to-file>

but when i try this:

mvn install:install-file -Dfile=E:\jarFiles\utill-1.0.jar -DlocalRepositoryPath=E:\repo

it gives me the following error:

The artifact information is incomplete or not valid:
[ERROR] [0]  'groupId' is missing.
[ERROR] [1]  'artifactId' is missin
[ERROR] [2]  'packaging' is missing
[ERROR] [3]  'version' is missing.
Mr.Q
  • 4,316
  • 3
  • 43
  • 40
  • First the headline of the link talks about `..custom POM`. Furthermore if you like to install the artifact into the local repository you simple can do that by using `mvn install`. – khmarbaise May 02 '14 at 06:10
  • 1
    You need the answer at [Specifying Maven's local repository location as a CLI parameter](http://stackoverflow.com/questions/6823462/specifying-mavens-local-repository-location-as-a-cli-parameter). If it's a permanent change then you can specify it in your ~/.m2/settings.xml file – Steve C May 02 '14 at 06:26
  • 1
    no in that link i sent in the question i meant this line : If the JAR was built by Apache Maven, it'll contain a pom.xml in a subfolder of the META-INF directory, which will be read by default. In that case, all you need to do is: mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file -Dfile= – Mr.Q May 02 '14 at 06:35

5 Answers5

13

You have to provide that information (groupId, artifactId, packaging, version) too.

mvn install:install-file  -Dfile=path-to-your-artifact-jar \
                          -DgroupId=your.groupId \
                          -DartifactId=your-artifactId \
                          -Dversion=version \
                          -Dpackaging=jar \
                          -DgeneratePom=true

Check here for more details

Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
  • 1
    yes that is true but if you check the link i sent in the question, it says that if you have generated your jar files using maven , you dont need to provide this info – Mr.Q May 02 '14 at 06:02
  • @user3593084 : Check that jar contains pom file under META-INF directory – Abimaran Kugathasan May 02 '14 at 06:05
  • 1
    yes there is a pom file in the address ..\META-INF\maven\dependMav\utill – Mr.Q May 02 '14 at 06:08
8

This should work.

mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=<path-to-file>
Vishal Kumar
  • 111
  • 1
  • 2
  • 1
    Why should that work? Why did the asker's code not work? Please explain in your answer! –  Jun 14 '17 at 16:46
  • A simple `install:install-file` used `maven-install-plugin:2.4` for me. However, the functionality to use a pom found in the jar was apparently only introduced in `maven-install-plugin:2.5`, so this does in fact solve the problem. – jazzpi Jul 22 '20 at 12:36
2

Hi again guys i wanted to mention something, when i extracted the maven created jar file and copied the POM.xml file in a separate location and installed the jar file by referencing to it . it worked fine but i dont know why my first command din`t work! here is the command that worked;

  mvn install:install-file -Dfile=E:\jarFiles\utill-1.0.jar -DpomFile=E:\jarFiles\pom.xml -DloaclRepositoryPath=E:\repo 

by the way obviously mvn install , also works fine and installs the jar file to my local repository.

Mr.Q
  • 4,316
  • 3
  • 43
  • 40
  • by the may i wanted to add that the name of the pom file dosent matter because i rerun the command with pom file renamed to Notpom.xml and it worked fine. – Mr.Q May 02 '14 at 07:15
1

I think the error says it all. You dont even have to scratch your brain to get info out of it. It is a relevant error and straight to the point.

Refer: http://www.mkyong.com/maven/how-to-include-library-manully-into-maven-local-repository/

With your mvn install command, you need to provide groupID, artifactId, packaging and version. Check your pom for that information, from which you built the jar..

Sample command:

mvn install:install-file -Dfile=c:\kaptcha-{version}.jar -DgroupId=com.google.code -DartifactId=kaptcha -Dversion={version} -Dpackaging=jar

Sambhav Sharma
  • 5,741
  • 9
  • 53
  • 95
  • http://maven.apache.org/plugins/maven-install-plugin/examples/custom-pom-installation.html – Mr.Q May 02 '14 at 06:05
  • Obviously there is some problem with the jar.. did you check for the pom.xml in your jar? Extract it and check for the location ones.. – Sambhav Sharma May 02 '14 at 06:06
  • it is not a big pom file, it was auto generated with maven here is its contents: 4.0.0 dependMav utill jar 1.0 utill http://maven.apache.org – Mr.Q May 02 '14 at 06:13
0

I just had the same issue, and it was due to a corrupted jar file as suggested in the comments. I just replaced it and the command worked without any extra switches for groupid, packaging etc (because it was a maven jar already).

It turned out that the jar was corrupted by pushing it from Windows to a git repo then pulling onto a Linux box. The solution was to tell get that jars are binaries to it didn't convert the line endings - see here: Jar file gets corrupted after pushing to github

Sam West
  • 21
  • 4