JavaFX项目的有效JAR签名
我一直在使用各种配方来使用Maven POM为
JavaFX项目生成可运行的JAR文件.这些Stackoverflow问题中的每一个都描述了同样的问题.令人沮丧的是,针对同一目标似乎有几种不同的解决方案.
问题:
在命令行上执行JAR文件时出错.虽然Netbeans可以愉快地运行程序并调试程序. 诊断 有关于此的几个Stackoverflow和论坛问题(下面最有用的).尽管已知问题,但我还没有找到一个与JavaFX一起使用的明确解决方案.这些答案中描述的过程不是用于捆绑JavaFX JAR的JavaFxPackager工具: > “Invalid signature file digest” error adding Janino package through Maven 常用方法: > “Invalid signature file” when attempting to run a .jar …… 但是,当我们将相同的插件放在构建JavaFX JAR文件的POM中时,我们仍然得到:“无效的签名文件摘要…”错误.具体来说,我放置了< artifactId> maven-shade-plugin< / artifactId>首先在JavaFxPackager exec规则之前和之后.结果是 > Maven给出:“Manifest主要属性的无效签名文件摘要…”错误 **题*: 如何管理JavaFX应用程序.这是POM< build>部分Netbeans为JavaFX设置: <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions> <execution> <id>unpack-dependencies</id> <phase>package</phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <excludeScope>system</excludeScope> <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds> <outputDirectory>${project.build.directory}/classes</outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.3.2</version> <executions> <execution> <id>unpack-dependencies</id> <phase>package</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>${java.home}/../bin/javafxpackager</executable> <arguments> <argument>-createjar</argument> <argument>-nocss2bin</argument> <argument>-appclass</argument> <argument>${mainClass}</argument> <argument>-srcdir</argument> <argument>${project.build.directory}/classes</argument> <argument>-outdir</argument> <argument>${project.build.directory}</argument> <argument>-outfile</argument> <argument>${project.build.finalName}.jar</argument> </arguments> </configuration> </execution> <execution> <id>default-cli</id> <goals> <goal>exec</goal> </goals> <configuration> <executable>${java.home}/bin/java</executable> <commandlineArgs>${runfx.args}</commandlineArgs> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <compilerArgument>-Xlint:unchecked</compilerArgument> <!-- all --> <showWarnings>true</showWarnings> <showDeprecation>true</showDeprecation> <compilerArguments> <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib /jfxrt.jar</bootclasspath> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.16</version> <configuration> <additionalClasspathElements> <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement> </additionalClasspathElements> </configuration> </plugin> </plugins> </build> 根据以下答案使用的分片插件配置:“Invalid signature file” when attempting to run a .jar目前看起来像这样: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <!-- http://maven.apache.org/plugins/maven-shade-plugin/ --> <!-- http://docs.codehaus.org/display/MAVENUSER/Shade+Plugin --> <!-- http://zhentao-li.blogspot.com.au/2012/06/maven-shade-plugin-invalid-signature.html --> <version>2.3</version> <executions> <execution> <id>remove-sign-files</id> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>classes/META-INF/*.SF</exclude> <exclude>classes/META-INF/*.DSA</exclude> <exclude>classes/META-INF/*.RSA</exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin> 为了尽可能地让Netbeans脱离这个等式,我就跑了 > mvn包 在命令行上.这个问题似乎是一个常见的问题,我希望有人破解了JavFX捆绑其他JAR文件中的JavaFX构建代码. 其他链接: > How to tell the maven-shade-plugin to preserve signatures? 解决方法
我有一个非常相似的问题;当我在项目中包含一个签名的JAR(bouncycastle)时.它的签名被逐字重新打包,导致明显的SecurityException:
过滤所有种类都失败了;适合我的解决方案在pom.xml中看起来像这样: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions> <execution> <id>unpack-dependencies</id> <phase>package</phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <excludes>META-INF/*.SF,META-INF/*.DSA,META-INF/*.RSA</excludes> ... </configuration> </execution> </executions> </plugin> 在带有“排除”模式的新行之后,我省略了一些行. 希望能帮助其他人解决同样的问题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |