6

I have a load of 3rd party JAR files (around 40 different JARs from various SDKs I'm using) sitting in a folder on my hard drive. I want to declare those JARs as dependencies in my future maven projects.

I cannot obtain those JARs from the worldwide global maven repository as you could with e.g. Log4J, JUnit, Velocity etc, since they are not available there.

How do I get these JAR files from my local folder into my company global (but internal) maven repository (Nexus)? What would be the necessary steps? The best solution would be a programmatical one, if that's possible at all.

I'm confused that I could not find any solution to my problem using Google, because I imagine this to be a very widespread problem. So maybe I'm thinking in a wrong direction.

Thank you very much!

HombreFab
  • 223
  • 1
  • 4
  • 7

1 Answers1

10

You can install the libraries to your local repository with the maven-install-plugin (install-file goal - see example).

You can deploy the libraries to your remote repository (Nexus) with the maven-deploy-plugin (deploy-file goal - see example).

You can also use the Nexus web application to upload the libraries to nexus (see Nexus Book - Uploading Artifacts).

FrVaBe
  • 47,963
  • 16
  • 124
  • 157
  • Thank you for your reply, @FrVaBe. Is there any way to do this from Java using any of the Maven APIs? I tried using the Invoker, but according to [the documentation](http://maven.apache.org/plugins/maven-invoker-plugin/), the deploy goal is not supported. – HombreFab Jul 13 '12 at 06:39
  • @HombreFab I have no experience with programmatically executing maven tasks but it should be possible to configure the maven-deploy-plugin in a pom.build.plugin section and trigger the invoker:install goal. In your case the most simple automated method for me seems to be a batch-script which executes the different `mvn deploy:deploy-file` commands. – FrVaBe Jul 13 '12 at 06:58
  • 1
    Thank you. I'll iterate over my JAR-files in Java and execute the 'mvn deploy:deploy-file' by [calling the commandline](http://www.linglom.com/2007/06/06/how-to-run-command-line-or-execute-external-application-from-java/) from java directly for each file. That'll do it. – HombreFab Jul 13 '12 at 07:09
  • Hello, I've written a small tool which generates a pom.xml for exactly this purpose, perhaps my [blog post "How to bulk install 1000 3rd party JARs to Maven local & deploy to remote repo"](http://blog2.vorburger.ch/2015/02/how-to-bulk-install-1000-3rd-party-jars.html) and the [source of my MavenBulkInstallDeploy project](https://github.com/vorburger/MavenBulkInstallDeploy) could be useful to someone. – vorburger Feb 27 '15 at 13:07