java - Maven jarsigner 插件在发布期间不起作用

标签 java maven maven-3 maven-release-plugin jarsigner

我需要对发布的 jar 进行签名,我想使用 maven jarsigner 插件来完成。所以我这样添加:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jarsigner-plugin</artifactId>
            <version>1.2</version>
            <configuration>
                <archive>target/${myarchive}.jar</archive>
                <keystore>${key.location}</keystore>
                <storepass>${keypass}</storepass>
                <alias>${key.alias}</alias>
                <verbose>true</verbose>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>sign</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

我在命令行中提供了缺少的参数。

当我运行 mvn install 时,一切正常,存档已签名。但是当我运行 release:prepare release:perform 时,jarsigner 插件失败:`The parameters 'alias' for goal org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign are missing or无效'

当我在 Debug模式下运行时,我看到以下内容:

对于 mvn install:

[DEBUG] Configuring mojo org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign from plugin realm ClassRealm[plugin>org.apache.m
aven.plugins:maven-jarsigner-plugin:1.2, parent: sun.misc.Launcher$AppClassLoader@6d6f0472]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign' with basic configurator -->
[DEBUG]   (f) alias = myalias
[DEBUG]   (f) archive = myarchive
[DEBUG]   (f) arguments = []
[DEBUG]   (f) keystore = mykeystore
[DEBUG]   (f) processAttachedArtifacts = true
[DEBUG]   (f) processMainArtifact = true
[DEBUG]   (f) project = MavenProject: com.playtech.chat:ums_supportchatapplet:12.4-SNAPSHOT @ *********\pom.xml
[DEBUG]   (f) removeExistingSignatures = false
[DEBUG]   (f) skip = false
[DEBUG]   (f) storepass = changeit
[DEBUG]   (f) verbose = true
[DEBUG] -- end configuration --

但是当我运行 release:prepare release:perform 时,我看到:

Configuring mojo org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-jarsigner-plugin:1.2, parent: sun.misc.Launcher$AppClassLoader@553f5d07]
[INFO] [DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign' with basic configurator -->
[INFO] [DEBUG]   (f) archive = myarchive
[INFO] [DEBUG]   (f) arguments = []
[INFO] [DEBUG]   (f) processAttachedArtifacts = true
[INFO] [DEBUG]   (f) processMainArtifact = true
[INFO] [DEBUG]   (f) project = MavenProject: com.playtech.chat:ums_supportchatapplet:12.4.0.1 @ *****\pom.xml
[INFO] [DEBUG]   (f) removeExistingSignatures = false
[INFO] [DEBUG]   (f) skip = false
[INFO] [DEBUG]   (f) verbose = true
[INFO] [DEBUG] -- end configuration --

所以除了archive属性,其他属性在发布时都被忽略了。

非常感谢任何想法。

最佳答案

找到答案了。

简而言之,-D 参数不会从命令行传递到发布插件。
应使用 -Darguments=

有关更多详细信息,请阅读此 blog post这帮助我解决了这个问题。

关于java - Maven jarsigner 插件在发布期间不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10698558/

相关文章:

java - GAE 作为桌面应用程序 (Swing) 的服务提供者

Maven 在多个插件执行之间共享配置

testing - Cucumber-JVM Maven 集成问题

Java TCP 套接字编程 - 在服务器上构建大字符串以在客户端上打印

datetime - Java日期在单个类中处理: store date,时间和时区

java - Jenkins 自动部署tomcat 7

java - 将 Artifact 从项目添加到本地存储库

maven - 使用 Maven exec 插件启动 Windows 批处理脚本会阻止构建,即使该脚本使用 "start"

eclipse - Tycho 是否适用于 Eclipse 3.5

java - 获取特定的HashMap实体并获取详细信息