0

I have a jar file local to my project and I need to install the jar as a 3rd party file or just install this jar using mvn install:install command so that the jar will be available in .m2 folder (under repositories) and later I can declare the dependency in pom.xml which will not throw error, tried to execute in different ways but throws the below error.

Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.5 .2:install-file (default-cli) on project sampl-project: The specified file 'E:\sample-11.jar' not exists

The below combinations I tried to run mvn install:install but failed miserably.

mvn install:install-file -DgroupId=sample.groupId -DartifactId=samplefields -Dpackaging=jar -Dversion=11 -D file=E:\sample-11.jar -DgeneratePom=true

mvn install:install-file -DgroupId=sample-groupId -DartifactId=samplefields -Dpackaging=jar -Dversion=11 -D file=E:\sample-11.jar -DgeneratePom=true

mvn install:install-file "-DgroupId=sample.groupId" -DartifactId=samplefields -Dpackaging=jar -Dversion=11 -D file=E:\sample-11.jar -DgeneratePom=true

mvn install:install-file "-DgroupId=sample.groupId" "-DartifactId=samplefields" "-Dpackaging=jar" "-Dversion=11" "-D file=E:\sample-11.jar" "-DgeneratePom=true"

Further, I also tried to place my jar in different locations and different names and run maven install:install but same error I get

enter image description here

Maven Version -

Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)

Links I gone thru, but they are of different issue: Error with mvn install local jar: Failed to execute goal org.apache.maven.plugins:maven-install-plugin...(Is a directory) -> [Help 1] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install-file maven

Suresh
  • 1,491
  • 2
  • 22
  • 27

2 Answers2

1

The mistake I did was to mention the version and use extension (.jar) name also into the command and that created the issue.

Invalid Command:

mvn install:install-file -DgroupId=sample.groupId -DartifactId=samplefields -Dpackaging=jar -Dversion=11 -D file=E:\sample-11.jar -DgeneratePom=true

Valid Command:

mvn install:install-file -DgroupId=sample.groupId -DartifactId=samplefields -Dpackaging=jar -Dversion=11 -D file=E:\sample -DgeneratePom=true

-11.jar text removed from command and it worked flawless! Hope this helps someone out here.

enter image description here

Suresh
  • 1,491
  • 2
  • 22
  • 27
-1
  1. In this error you see that the name of the artifact is not found :

the specified file 'E:\ -11.jar' not exists.

  1. make sure that you have the permission to copy this file.

  2. for all commands, i see that you have an space between -D and the file=E:\sample-11.jar.

So you shoud remove the space and run the command line like this :

mvn install:install-file -DgroupId=sample.groupId -DartifactId=samplefields -Dpackaging=jar -Dversion=11 -Dfile=E:\sample-11.jar -DgeneratePom=true
skillup
  • 190
  • 6