Issue
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
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
Solution
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.
Answered By - mannedear
Answer Checked By - Willingham (JavaFixing Volunteer)