Java maven是否能够在没有任何源的情况下将单个*.dll打包到jar中?
我想将*.dll作为第三方lib添加到我的存储库中,在打包过程中,只需将它们打包到*.jar中,签名并复制到某个特定的文件夹Java maven是否能够在没有任何源的情况下将单个*.dll打包到jar中?,java,maven,dll,jar,jacob,Java,Maven,Dll,Jar,Jacob,我想将*.dll作为第三方lib添加到我的存储库中,在打包过程中,只需将它们打包到*.jar中,签名并复制到某个特定的文件夹 签名和应对都做得很好,并且工作正常(正如使用maven依赖插件和maven jarsigner插件所期望的那样)。但我没有找到任何方法来自动将单个dll打包到jar(没有maven assembly插件那样的任何源代码) 我当时看到的解决方案是:不向我的存储库添加“纯”dll,而是已经打包到jar库(由我自己打包)。。。但这不是一个好主意,我想)我建议通过maven
签名和应对都做得很好,并且工作正常(正如使用maven依赖插件和maven jarsigner插件所期望的那样)。但我没有找到任何方法来自动将单个dll打包到jar(没有maven assembly插件那样的任何源代码)
我当时看到的解决方案是:不向我的存储库添加“纯”dll,而是已经打包到jar库(由我自己打包)。。。但这不是一个好主意,我想)我建议通过maven assembly插件将dll打包为zip存档,并让该模块将zip存档作为附加到常用pom的附件进行部署。该项目的打包应该是pom而不是默认的。 如果我下载一个jar,发现里面有dll,我会有点困惑,
但是如果您愿意,您可以通过maven assembly插件创建jar或使用maven jar插件。听起来您已经成功地检索了.dll(使用依赖插件)并对其进行了签名(jarsigner插件),它位于
${project.build.directory}
(默认为target
)
如果这是正确的,请尝试一下:
- 将项目的
打包定义为
jar
- 检索DLL
- 确保
目标绑定到jarsigner:sign
阶段。默认情况下,它绑定到prepare package
,我们需要确保package
在jarsigner:sign
之前运行jar:jar
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jarsigner-plugin</artifactId> <version>1.2</version> <executions> <execution> <id>sign</id> <phase>prepare-package</phase> <!-- important --> <goals> <goal>sign</goal> </goals> </execution> </executions> </plugin>
- 现在,运行
应该会给您一个包含已签名DLL的jarmvncleanpackage
- 如果JACOB需要manifest config,那么下面将解释如何执行此操作李>
祝你好运 有必要将这些DLL打包到jar!(请参阅jacob项目)在小程序中使用jacob。如果您能给我一个简单的示例,说明如何打包单个文件(dll),我将不胜感激使用maven assemply plugin或maven jar plugin进行jar。我已经用与您提到的几乎相同的方式解决了这个问题。有一个问题-您应该将这些*.dll作为资源放在某个目录中……但我更愿意将这些*.dll作为第三方工件添加到存储库中,并通过artifactId而不是通过artifactId使用它们
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<!-- using this ID merges this config with default -->
<!-- So it should not be necessary to specify phase or goals -->
<!-- Change classes directory because it will look in target/classes
by default and that probably isn't where your dlls are. If
the dlls are in target then directoryContainingSignedDlls is
simply ${project.build.directory}. -->
<id>default-jar</id>
<configuration>
<classesDirectory>directoryContainingSignedDlls</classesDirectory>
<includes>
<include>**/*.dll</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>