简体   繁体   中英

Add jar into Maven project

I want to use this jar in a Maven project.

https://github.com/downloads/2checkout/2checkout-java/twocheckout-java-latest.jar

I know that the proper way is to add this jar into my local repository but I can't do this into every development machine. Is there any Maven plugin that can download this jar file and add it into my project?

There are only 3 options in a case like this:

  1. Convince the people of the project to put their releases in Maven Central. See Guide to uploading artifacts to the Central Repository for more information on that.
  2. Install a Maven proxy (eg Sonatype Nexus, see http://www.sonatype.org/nexus/ ) and upload the artifact manually. Each developer on the project can point to that proxy and will get the artifact.
  3. Use the maven-install plugin to have each developer install the jar on his own local repository.

You can add below dependency into your pom.xml

<dependency>
  <groupId>com.twocheckout</groupId>
  <artifactId>twocheckout-java</artifactId>
  <version>0.1.0</version>
</dependency>

The usual way to deal with this sort of situation is to use a shared repository such as nexus or artifactory. You configure the nexus repository to serve the locally-uploaded artifacts and you configure your pom to point to your nexus repository as one of the repositories where the artifact may be found. Then, you install the problematic artifact to the nexus repository (rather than every developer's local repository).

If desired, you can also configure your nexus to be a proxy for Maven Central (and all other repositories that you use) and have your pom configured to look only there. This results in a cache of all the artifacts that you use being held locally, which can improve performance and availability for your team (if they are co-located). This can be especially important if you have a dependency on a SNAPSHOT version that is stored in a remote repository.

The best way is to have a proxy repository installed in your corporate LAN and deploy these kind of jars in to "hosted" repositories. Then editing your settings.xml to have this as your repository.

The choice of local proxy varies from using a NAS based shared drive to using repository managers like 'Nexus' or 'Artefactory'. This way you can easily distribute the artefacts across developers and all other users.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM