Search code examples
mavengradlebuildmaven-3maven-central

Upload third party packages to my own maven repository server using maven


I am trying to upload third party packages (eg junit ) to my own repository server.

I did following things:
1)Added following thing in ~/.m2/settings.xml

<server>
      <id>thirdparty</id>
      <privateKey></privateKey>
      <passphrase></passphrase>
</server>

2)Went to a package that is alredy cached on my local machine at ~/.m2/repository/junit/junit/3.8.1

3)Issued following command to upload the package to my remote repository

mvn deploy -DaltDeploymentRepository=thirdparty::default::http://localhost:8000/mavenrepository/thirdparty

Am getting following error:

ERROR] The goal you specified requires a project to execute but there is no POM in this directory 
(/Users/myuser/.m2/repository/junit/junit/3.8.1). Please verify you invoked Maven from the correct directory. -> [Help 1]
org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to execute but there is no POM in this directory (/Users/myuser/.m2/repository/junit/junit/3.8.1). Please verify you invoked Maven from the correct directory.
    at 

There is no pom.xml in this directory, but there is a file called junit-3.8.1.pom

If i rename junit-3.8.1.pom to pom.xml and then issue the above deploy command then everything is working fine and maven is able to deploy the package to my repository.

Why is my command not working? How do we deploy packages to my remote repository without renaming the file?Am i issuing wrong command to deploy the package?


Solution

  • By default maven expects the pom file name as pom.xml. To use other name, use the -f option as follows:

    mvn deploy -DaltDeploymentRepository=thirdparty::default::http://localhost:8000/mavenrepository/thirdparty -f junit-3.8.1-pom.xml