Maven shade插件包装DLL

问题描述 投票:11回答:1

我必须在我的项目中添加一个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?

java maven dll
1个回答
0
投票

这个解决方案适用于我的JavaFX-OpenCV项目

  1. 在没有DLL文件的情况下打包您的项目。
  2. DLL文件复制并粘贴到jar文件目录中。
  3. 现在您可以运行您的应用程序,因为所有DLL文件现在都在您的jar应用程序的类路径中。

你的目录应该是这样的: /target/application.jar /target/your_DLL_files.dll

© www.soinside.com 2019 - 2024. All rights reserved.