【问题标题】:Maven + jarsigner + test classes = errorMaven + jarsigner + 测试类 = 错误
【发布时间】:2014-03-19 18:02:07
【问题描述】:

我有一个包含一些测试用例的 Maven 项目。今天我尝试添加 jarsigner 插件,现在测试失败了:

java.lang.SecurityException: 类“types.AccountType”的签名者信息与同一包中其他类的签名者信息不匹配

测试类在同一个包中,可以访问包私有方法等。我认为发生此错误是因为 junit 测试类没有被签名,而被测试的类是。

有没有人对如何避免这个问题提出建议?我有一些想法,但不知道如何实施:

  1. 使测试阶段使用类而不是 jar 文件。
  2. 将测试类放入自己的 jar 文件并签名。

【问题讨论】:

  • 你是如何解决这个问题的?

标签: maven junit jarsigner


【解决方案1】:

我今天遇到了这个问题,问题就像你多年前猜到的那样(签名顺序问题)。这是对我的修复(更改安装阶段):

        <plugin>
            <artifactId>maven-jarsigner-plugin</artifactId>
            <version>${maven-jarsigner-plugin.version}</version>
            <executions>
                <execution>
                    <id>sign</id>
                    <!-- note: this needs to be bound after integration tests or they will fail re: not signed -->
                    <phase>install</phase>
                    <goals>
                        <goal>sign</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <tsa>http://sha256timestamp.ws.symantec.com/sha256/timestamp</tsa>
                <keystore>${project.basedir}/.conf/Keystore</keystore>
                <alias>Alias</alias>
                <storepass>{1234}</storepass>
            </configuration>
        </plugin>

Jars 仍然被签名并且集成测试再次工作。

【讨论】:

    猜你喜欢
    • 2011-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    • 2018-11-19
    • 1970-01-01
    相关资源
    最近更新 更多