我需要对已发布的 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 插件失败:`目标 org.apache.maven.plugins:maven-jarsigner-plugin:1.2:sign 的参数'alias'丢失或无效'

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

为了 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= 应该使用。

欲了解更多详情,请阅读此内容 博客文章 这帮助我解决了这个问题。

其他提示

在 cmd 提示符下输入此命令:

keytool -list -keystore [keystore location here]

“myalias”别名是否在该特定密钥库中?如果没有,你需要 创建一个.

我看到的唯一可能出错的事情是该密钥库的密码是否不正确。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top