签署使用maven-assembly插件创建的jar文件 [英] Sign a jar file created with maven-assembly plugin

查看:118
本文介绍了签署使用maven-assembly插件创建的jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个程序集然后签名。我的问题是,jarsigner不是汇编,只是独立的jar文件。你能告诉我这是什么问题吗?在使用Ant多年后,Maven对我来说似乎是神奇的..我无法看到插件合作的方式并将信息传递给对方。

I'd like to build an assembly and then sign it. My problem is that the jarsigner signs not the assembly, only the standalone jar file. Could you tell me what is the problem? Maven seems like 'magic' to me after having used Ant for years.. I can't see the way the plugins cooperate and pass information to each other.

执行后 mvn install ,我得到两个jar文件,一个名为 example-1.0.0-SNAPSHOT.jar ,这是签名,一个名为 example-1.0.0-jar-with-dependencies.jar ,并且没有签名。我不需要单独一个,只需要汇编,但签名。

After executing mvn install, I get two jar files, one called example-1.0.0-SNAPSHOT.jar and this is signed, and one called example-1.0.0-jar-with-dependencies.jar and this is not signed. I do not need the solo one, only the assembly, but that signed.

这是我的pom.xml:

Here is my pom.xml:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jarsigner-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <id>sign</id>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <keystore>${project.basedir}\keystore\mykeystore</keystore>
                    <alias>myalias</alias>
                    <storepass>...</storepass>
                    <keypass>...</keypass>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>make-my-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.example.FooBar</mainClass>
                        </manifest>
                    </archive>
                    <appendAssemblyId>true</appendAssemblyId>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
    </build>


推荐答案

你应该尝试把maven-assembly-plugin进入准备包阶段而不是包阶段:

You should try to put the maven-assembly-plugin into the prepare-package phase instead of the package phase:

  <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
        <execution>
            <id>make-my-assembly</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
    ...
</plugin>

这篇关于签署使用maven-assembly插件创建的jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆