有没有办法使用maven安装第三方源和javadoc JAR?
答案 0 :(得分:3)
Guide to installing 3rd party JARs
如果你想使用那里提到的关于maven-install-plugin 2.5版的功能(如果JAR是由Apache Maven构建的,它将在META-INF目录的子文件夹中包含一个pom.xml,默认情况下,maven-install-plugin会读取:2.5),然后你可以运行:
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=<path-to-jar-file>
为javadoc生成jar,源使用例如:
如果要为已安装的jar安装辅助工件(例如sources jar),请按照此处描述的步骤进行操作:Installing Secondary Artifacts
答案 1 :(得分:1)
有关如何安装第三方javadoc JAR的信息,请参阅:How to deploy Javadoc jar file。
答案 2 :(得分:0)
至少有三种方法可以将第三方JAR添加到Maven项目中。
我将专注于第三种方法,我发现它更清洁,不需要任何mvn命令,并且可以从任何IDE上直接使用。
步骤1 :在pom.xml中添加本地“虚拟”存储库的位置
<repositories>
<repository>
<id>repo</id>
<name>repo</name>
<url>file:${project.basedir}/src/main/resources/lib</url>
</repository>
</repositories>
这里“虚拟”存储库位置是我的项目目录的“ lib”文件夹
第2步:将jar依赖项添加到pom.xml
<dependency>
<groupId>com.cloudera.impala</groupId>
<artifactId>impala-frontend</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
选择任何groupId,但请确保artifactId和版本的格式为<artifactId>-<version>.jar
(第三方jar的名称)
第3步:根据本地“虚拟”存储库中第2步中提到的groupId,artifactId和版本创建文件夹结构。因此,在这种情况下,文件夹指令应为/src/main/resources/lib/com/cloudera/impala/impala-frontend/0.1-SNAPSHOT/
将您的jar放在版本文件夹中并构建您的项目。 您将获得以下输出,将您的“虚拟”存储库视为您的第3方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]