How to install third party source and javadoc JARs?

前端 未结 3 1003
臣服心动
臣服心动 2020-12-21 06:27

Is there way to install third party source and javadoc JARs by using maven?

相关标签:
3条回答
  • 2020-12-21 06:43

    There are atleast three approaches in which 3rd party JARs can be added to Maven projects.

    1. Install manually using mvn install command
    2. Adding the location of jar file in pom dependency with the the following tag system
    3. Creating a 'dummy' maven repository pointing to jar location.

    I will focus on third approach which I find more cleaner and does not require any mvn command and works out of box from any IDE.

    Step 1: Add the location of local 'dummy' repository in pom.xml

    <repositories>
        <repository>
            <id>repo</id>
            <name>repo</name>
            <url>file:${project.basedir}/src/main/resources/lib</url>
        </repository>
    </repositories>
    

    Here the 'dummy' repository location is the 'lib' folder of my project directory

    Step 2 : Add the jar dependency into your pom.xml

        <dependency>
            <groupId>com.cloudera.impala</groupId>
            <artifactId>impala-frontend</artifactId>
            <version>0.1-SNAPSHOT</version>
        </dependency>
    

    choose any groupId but make sure that artifactId and version is of the format <artifactId>-<version>.jar ( Name of 3rd party jar)

    Step 3 : Create the folder structure as per the groupId,artifactId and version mentioned in the Step 2 in your local 'dummy' repository. So in this case the folder struction would be /src/main/resources/lib/com/cloudera/impala/impala-frontend/0.1-SNAPSHOT/

    Place your jar in the version folder and build your project. You will get the following output which treats your 'dummy' repository to be the provider of your 3rd party jar.

    [INFO] Downloading from repo: file:C:\Users\skumar\eclipse-workspace\chdQueryBuilder/src/main/resources/lib/com/cloudera/impala/impala-frontend/0.1-SNAPSHOT/maven-metadata.xml
    [INFO] Downloading from repo: file:C:\Users\skumar\eclipse-workspace\chdQueryBuilder/src/main/resources/lib/com/cloudera/impala/impala-frontend/0.1-SNAPSHOT/impala-frontend-0.1-SNAPSHOT.pom
    [WARNING] The POM for com.cloudera.impala:impala-frontend:jar:0.1-SNAPSHOT is missing, no dependency information available
    [INFO] Downloading from repo: file:C:\Users\skumar\eclipse-workspace\chdQueryBuilder/src/main/resources/lib/com/cloudera/impala/impala-frontend/0.1-SNAPSHOT/impala-frontend-0.1-SNAPSHOT.jar
    [WARNING] Could not validate integrity of download from file:C:\Users\skumar\eclipse-workspace\chdQueryBuilder/src/main/resources/lib/com/cloudera/impala/impala-frontend/0.1-SNAPSHOT/impala-frontend-0.1-SNAPSHOT.jar: Checksum validation failed, no checksums available
    [WARNING] Checksum validation failed, no checksums available from repo for file:C:\Users\skumar\eclipse-workspace\chdQueryBuilder/src/main/resources/lib/com/cloudera/impala/impala-frontend/0.1-SNAPSHOT/impala-frontend-0.1-SNAPSHOT.jar
    [INFO] Downloaded from repo: file:C:\Users\skumar\eclipse-workspace\chdQueryBuilder/src/main/resources/lib/com/cloudera/impala/impala-frontend/0.1-SNAPSHOT/impala-frontend-0.1-SNAPSHOT.jar (7.0 MB at 79 MB/s)
    [INFO] 
    
    
    0 讨论(0)
  • 2020-12-21 07:02

    For info specifically about how to install 3rd party javadoc JARs see: How to deploy Javadoc jar file.

    0 讨论(0)
  • 2020-12-21 07:06

    Guide to installing 3rd party JARs

    If you want to use the feature mentioned there about version 2.5 of the maven-install-plugin (if the JAR was built by Apache Maven, it'll contain a pom.xml in a subfolder of the META-INF directory, which will be read by default by maven-install-plugin:2.5), then you can run:

    mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-fi‌​le -Dfile=<path-to-jar-file>
    

    To generate the jars for the javadoc and the sources use e.g.:

    Maven Deploy Plugin

    Maven Javadoc plugin

    Maven Source plugin

    If you want to install a secondary artifact (such as the sources jar) for an already installed jar, then follow the step described here: Installing Secondary Artifacts

    0 讨论(0)
提交回复
热议问题