【发布时间】:2013-10-23 01:58:49
【问题描述】:
要使用外部 com 对象,我必须将 Jacob jar 和 dll 库包含到我的 Jenkins 插件中。我找到了使用 Jacob 的 jacob_excel_reader plugin,但该解决方案并不让我满意。开发者在pom.xml文件中添加了jar依赖:
<dependency>
<groupId>com.jacob</groupId>
<artifactId>jacob</artifactId>
<version>1.17-M2</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jacob.jar</systemPath>
</dependency>
并通过参数集成dll文件:
-Djava.library.path=${workspace_loc:jacob_excel_reader}\lib
这是集成 dll 的唯一方法吗?我尝试了另一种方法,但我卡在了一半,我绝对需要你的帮助!
首先我将jar和dll文件的依赖添加到pom.xml:
<dependency>
<groupId>net.sf.jacob-project</groupId>
<artifactId>jacob</artifactId>
<version>1.14.3</version>
</dependency>
<dependency>
<groupId>net.sf.jacob-project</groupId>
<artifactId>jacob</artifactId>
<version>1.14.3</version>
<classifier>x86</classifier>
<type>dll</type>
</dependency>
并配置将dll文件复制到target/APPNAME/WEB-INF/lib:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<excludeTransitive>true</excludeTransitive>
<includeArtifactIds>jacob</includeArtifactIds>
<includeTypes>dll</includeTypes>
<failOnMissingClassifierArtifact>true</failOnMissingClassifierArtifact>
<silent>false</silent>
<outputDirectory>target/APPNAME/WEB-INF/lib</outputDirectory>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
当我运行 mvn package 时,默认测试会抛出警告:
SEVERE: Failed Inspecting plugin C:\...\AppData\Local\Temp\hudson7697228528744044800tmp\the.jpl
java.util.zip.ZipException: error in opening zip file
但它会将 dll 和 jar 文件复制到 target/APPNAME/WEB-INF/lib。 为什么还要复制 jar 文件以及导致 ZipException 的原因?
在插件执行期间插件抛出:
FATAL: no jacob-1.14.3-x86 in java.library.path
java.lang.UnsatisfiedLinkError: no jacob-1.14.3-x86 in java.library.path
并且找不到dll文件,为什么?我可以在java.library.path中添加target/APPNAME/WEB-INF/lib不使用上面的参数吗?
【问题讨论】:
标签: maven tomcat jenkins jenkins-plugins jacob