我必须在我的项目中添加一个JNI模块。
我在Maven中将模块安装为两个不同的工件: jar库:
mvn install:install-file -DgroupId=com.test -DartifactId=ssa -Dversion=1.0 -Dpackaging=jar -Dfile=ssa.jar和带有DLL的运行时库
mvn install:install-file -DgroupId=com.sirio -Dpackaging=ddl -DartifactId=ssa-runtime -classifier=windows-x86 -Dversion=1.0 -Dfile=SSADll.dll在我的maven项目中,我添加了以下依赖项:
<dependency>
<groupId>com.test</groupId>
<artifactId>ssa</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.test</groupId>
<artifactId>ssa-runtime</artifactId>
<classifier>windows-${arch}</classifier>
<type>dll</type>
<version>1.0</version>
<scope>runtime</scope>
</dependency>我的问题是,当我运行shade插件目标来创建一个带有依赖项的jar时,我得到了错误:
Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project ....: Error creating shaded jar: error in opening zip file sirio\ssa-runtime\1.0\ssa-runtime-1.0-windows-x86.dll 我怎样才能告诉shade插件不要解压dll?
发布于 2021-07-30 20:42:17
也许你需要的是以不同的方式打包。使用您使用的所有java类和库生成带有阴影的jar,然后将该jar和DLL打包到一个要发布的Zip文件中。为此,您可以使用带有zip描述符的maven-assembly-plugin,如下所示:
在你的pom.xml中
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>在zip.xml文件中:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>release</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>target</directory>
<includes>
<include>myapp.jar</include>
</includes>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>your.dll</source>
<fileMode>0644</fileMode>
</file>
</files>
</assembly>这样你就有了你需要在这个压缩包中释放的所有东西。我不知道这是否是最好的解决方案,但也许它解决了您的用例的问题。
发布于 2019-04-18 14:56:38
这个解决方案适用于我的JavaFX-OpenCV项目
DLL文件的项目打包。DLL文件复制并粘贴到jar文件目录中。DLL文件现在都位于jar应用程序的类路径上。<代码>H29<代码>G210您的目录应如下所示:
/target/application.jar
/target/your_DLL_files.dll
https://stackoverflow.com/questions/24011527
复制相似问题