Jenkens插件(使用Maven构建)和外部罐子
我正在尝试编写一个简单的Jenkins插件,它需要一个专有的外部库myAwesomePackage.jar。将外部jar包括在maven项目中经常在stackoverflow上讨论,这里的解决方案是 https://stackoverflow.com/a/7623805 似乎是解决这个问题的整洁方式。
I'm trying to write a simple Jenkins plugin, which requires a proprietary external library myAwesomePackage.jar. Including external jars into a maven project was often discussed here on stackoverflow and the solution here https://stackoverflow.com/a/7623805 seems to be the tidy way solve this.
所以我添加了我的罐子
mvn install:install-file \
-Dfile=./lib/path_to_jar/lib/myAwesomePackage.jar \
-DlocalRepositoryPath=my_repo \
-DcreateChecksum=true \
-DgroupId=myAwesomePackage \
-DartifactId=myAwesomePackage \
-Dversion=1 \
-Dpackaging=jar \
-DgeneratePom=true
并修改我的pom.xml看起来像
and modified my pom.xml that it looks like
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.532.3</version>
</parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>myPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>hpi</packaging>
<licenses>
<license>
<name> ... license name ... /name>
<url> ... license url ... </url>
</license>
</licenses>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
<repository>
<id>my_repo</id>
<url>file://${project.basedir}/my_repo</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.xml.rpc</artifactId>
<version>3.0-Prelude-Embedded-m2</version>
</dependency>
<dependency>
<groupId>myAwesomePackage</groupId>
<artifactId>myAwesomePackage</artifactId>
<version>1</version>
</dependency>
</dependencies>
</project>
我没有〜/ m2 / .settings文件。
And I don't have a ~/m2/.settings file.
我得到的错误信息(在运行 mvn package
之后)如下:
The error message, I get (after running mvn package
) is the following:
.....
Downloaded: http://repo.jenkins-ci.org/public/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar (96 KB at 79.2 KB/sec)
Downloaded: http://repo.jenkins-ci.org/public/xalan/xalan/2.7.1/xalan-2.7.1.jar (3102 KB at 150.7 KB/sec)
Downloaded: http://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/1.532.3/jenkins-war-1.532.3-war-for-test.jar (62097 KB at 467.9 KB/sec)
Downloading: file:///home/path_to/my_repo/myAwesomePackage/myAwesomePackage/1/myAwesomePackage-1.jar
Downloading: http://repo.maven.apache.org/maven2/myAwesomePackage/myAwesomePackage/1/myAwesomePackage-1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12:17.009s
[INFO] Finished at: Fri Jul 11 01:40:32 EDT 2014
[INFO] Final Memory: 12M/86M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project myPlugin: Could not resolve dependencies for project org.jenkins-ci.plugins:myPlugin:hpi:1.0-SNAPSHOT: Could not find artifact myAwesomePackage:myAwesomePackage:jar:1 in repo.jenkins-ci.org (http://repo.jenkins-ci.org/public/) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
所以我的问题是:
哪个是正确的将专有jar包含到jenkins插件中的方法,该插件是用maven构建的?
So my question is: Which is the right way to include a proprietary jar into a jenkins plugin, which is build with maven?
我的问题中描述的程序有效!
由于 -Dfile = ....
选项中的输入错误而发生错误,但maven没有给出任何错误我认为操作成功。
如Jigar Joshi的评论中所述, mvn clean install -X
有助于调试此类问题。
The procedure as described in my question works!
The error occurred due to a typing error within the -Dfile=....
option, but maven doesn't give any error I thought that operation was successful.
As described in the comments of Jigar Jos a mvn clean install -X
helps to debug such troubles.