gpt4 book ai didi

java - maven 是否能够在没有任何源的情况下将单个 *.dll 打包到 jar 中?

转载 作者:行者123 更新时间:2023-11-30 04:49:21 24 4
gpt4 key购买 nike

我想将 *.dll 作为第三方库添加到我的存储库中,在打包过程中只需将它们打包到 *.jar,对它们进行签名并复制到某个特定文件夹。

<小时/>

签名和应对做得很好并且工作正常(正如使用 maven-dependency-plugin 和 maven-jarsigner-plugin 所预期的那样)。但我没有找到任何方法来自动将单个dll打包到jar中(没有像maven-assemble-plugin那样的任何源)。

<小时/>

我当时看到的解决方案:向我的存储库添加不是“纯”dll,而是已经打包到 jar lib(我自己打包)...但这不是一个好主意,我猜)

最佳答案

听起来您已经成功检索了 .dll(使用依赖插件)并对其进行了签名(jarsigner 插件),并且它位于您的 ${project.build.directory} 中的某个位置(默认为到目标)。

如果这是正确的,请尝试一下:

  • 将项目的打包定义为jar
  • 检索 dll
  • 确保 jarsigner:sign 目标绑定(bind)到 prepare-package 阶段。它默认绑定(bind)到 package,我们需要确保 jarsigner:signjar: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>
  • 配置 jar 插件以包含签名的 dll

    <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>
  • 现在,运行 mvn clean package 应该会为您提供一个包含签名 dll 的 jar。

  • 如果 JACOB 需要 list 配置,则有 docs解释如何执行此操作。

祝你好运!

关于java - maven 是否能够在没有任何源的情况下将单个 *.dll 打包到 jar 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10191485/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com