简体   繁体   中英

How are third party tools such as this accessed within Java?

https://github.com/bvanalderweireldt/concurrent-unique-queue

I have tried to set up a Maven dependency within IntelliJ, but I am not sure how the contents of this repository should be built and imported into a Java project. Could someone with more experience please advise on how this is done?

Kind regards,

L

If you want to use this project in another project, you will create a dependency to this using the dependency entry mentioned on the github readme :

<dependency>
  <groupId>com.hybhub</groupId>
  <artifactId>concurrent-util</artifactId>
  <version>0.1</version>
</dependency>

For this, you need the artifact in your local maven repository*. For this, you need to build this project or use a reference from Maven Central (Thanks @Mark Rotteveel )

Clone the project locally, you need to build it in one of the following ways

  1. Build it from the command line: Navigate to the project's location in your shell (bash or cmd) and run mvn install This will build the project and add the artifact (jar) to the local .m2 repository.

  2. Import to Intellij Idea (File -> New -> From Existing Sources). Once imported, build this project from the "Maven Projects" view.

Once you have done this, you can use this in other projects using the <dependency> entries

*For production ready apps, you may want to have a common maven repository for team your like Nexus or Artifactory and use that to maintain artifacts. You would also have a build system like Jenkins.

In the link you gave it had the dependency Maven entry for that library.

<dependency>
  <groupId>com.hybhub</groupId>
  <artifactId>concurrent-util</artifactId>
  <version>0.1</version>
</dependency>

That entry would need to be nested into you <dependencies> tag. Like the example below.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>Maven Quick Start Archetype</name>
  <url>http://maven.apache.org</url>

  <dependencies>
    <dependency>
      <groupId>com.hybhub</groupId>
      <artifactId>concurrent-util</artifactId>
      <version>0.1</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.2</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project> 

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