To use an external com object I have to include the Jacob jar and dll library into my Jenkins plugin. I found the jacob_excel_reader plugin which use Jacob, but the solution doesn't satisfy me. The developer added the jar dependency to the pom.xml
file:
<dependency>
<groupId>com.jacob</groupId>
<artifactId>jacob</artifactId>
<version>1.17-M2</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jacob.jar</systemPath>
</dependency>
and integrates the dll file via the argument:
-Djava.library.path=${workspace_loc:jacob_excel_reader}\lib
Is this the only way to integrate a dll? I tried it another way but I got stuck halfway and I definitely need your help!
First I added the dependency for the jar and dll file to the 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>
and configure that the dll file will be copied to 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>
When I run mvn package
the default tests throw a warning:
SEVERE: Failed Inspecting plugin C:\...\AppData\Local\Temp\hudson7697228528744044800tmp\the.jpl
java.util.zip.ZipException: error in opening zip file
but it copies the dll and jar file to target/APPNAME/WEB-INF/lib
. Why does it copy the jar file too and what causes the ZipException?
During the plugin execution the plugins throws:
FATAL: no jacob-1.14.3-x86 in java.library.path
java.lang.UnsatisfiedLinkError: no jacob-1.14.3-x86 in java.library.path
and cannot find the dll file, why? Can I add target/APPNAME/WEB-INF/lib
to the java.library.path
without using the argument above?