2

My team is using Maven for our builds and I was given some Jars for a tool that the software is using. The company that sent the Jars is a non Maven shop, so they just sent raw .jar files. In my local code I created some Maven dependencies for these Jars using this style:

<dependency>
    <artifactId>ThirdParty</artifactId>
    <groupId>made.up.url.org</groupId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>C:/pathToTheJars/ThirdPartyJarOne.jar</systemPath>
</dependency>

In all of the development there are around 25 of these custom jar files we need to load in. The other developers might not have the files like I do and these MVN Poms are checked into source control to be used in other environments outside development.

Is there some way to create a private "Maven Repo" so we can host these needed files internally and then have paths and urls point to our private locations? This would allow us to check the POM into source control, keep the jars out of source control, let Maven be Maven, and still use third party jars we don't want to "share".

Walls
  • 3,972
  • 6
  • 37
  • 52
  • There's a very good repository software: http://www.sonatype.org/nexus/ but I think it's paid. Or you can even use github as a repo http://stackoverflow.com/questions/14013644/hosting-a-maven-repository-on-github/14013645#14013645 – bruno_cw Nov 16 '15 at 14:33
  • You can of coure use the OSS version of Nexus...or Artifactory or Archiva... – khmarbaise Nov 16 '15 at 14:40

3 Answers3

4

If your team is using Nexus, you can deploy non-maven jars there. You can come up with any groupId, artifactId and version to those jars.

mvn deploy:deploy-file -DgroupId=some.groupId -DartifactId=some.artifactId -Dversion=1.0 -Dpackaging=jar -Dfile=TheNonMavenJarFile.jar -DrepositoryId=YourRepoID -Durl=UrlToYourRepository

After the deploy everyone can use the jars as normal dependency

<dependency>
    <groupId>some.groupId</groupId>
    <artifactId>some.artifactId</artifactId>
    <version>1.0</version>
</dependency>
Teemu
  • 438
  • 3
  • 11
  • I think you also have to add a `` tag, no? – bruno_cw Nov 16 '15 at 14:47
  • Depends on which repository the jars are deployed. They can be deployed into some repository which has been already configured in m2.settings, for example. – Teemu Nov 16 '15 at 14:51
  • @Teemu I have not heard of Nexus so I doubt we are using that. What is Nexus? Can you link to their site or have the full company name or something so I can do a better search for it. – Walls Nov 16 '15 at 14:54
  • @Walls its sonatype.org/nexus – bruno_cw Nov 16 '15 at 15:17
2

Yes you can. It is a bit of a hassle to explain though so you should look into this documentation which explains how to set an internal repository without the need for Nexus. Using Nexus will make most of the work for you though.

Aaron
  • 24,009
  • 2
  • 33
  • 57
1

You can also use github as a repo, provided you can create private repositories (unless you want your repo public).

The details on how to set it up are answered on this question.

Hosting a Maven repository on github

Community
  • 1
  • 1
bruno_cw
  • 994
  • 1
  • 8
  • 22