如果使用 keytool-maven-plugin 已经存在证书,如何跳过 importCertificate 目标?
How to skip the importCertificate goal if certificate is already exist by using keytool-maven-plugin?
我正在使用 keytool-maven-plugin 将 alias.cer 文件导入 java cacerts 存储,它工作正常。第二次构建项目时出现问题;出现错误,因为 alias.cer 文件已添加到存储中。我看不到任何参数来解决插件中的问题。有 'skip' 和 'skipIfExist' 参数。这些参数不是为了这个目的; skip 禁用插件,skipIfExist 如果商店已经存在则跳过。
我该如何解决这个问题?或者你知道这个目标的替代插件吗?
我意识到这个插件是在 java keytool 的基础上开发的。 keytool 中没有用于 'skip if certificate is already exist' 目的的任何参数。因此,我使用 'skip' 参数来处理这个问题,方法是添加一个在构建项目时使用的自定义参数。
<properties>
<cert.skip>true</cert.skip>
</properties>
<plugin>
<!-- https://mvnrepository.com/artifact/org.codehaus.mojo/keytool-maven-plugin -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>importCertificate</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<configuration>
<skip>${cert.skip}</skip>
<keystore>${JAVA_HOME}/lib/security/cacerts</keystore>
<storepass>changeit</storepass>
<alias>alias</alias>
<file>${basedir}/src/main/resources/alias.cer</file>
<noprompt>true</noprompt>
</configuration>
</plugin>
用法: mvn clean install -Dcert.skip=false
我正在使用 keytool-maven-plugin 将 alias.cer 文件导入 java cacerts 存储,它工作正常。第二次构建项目时出现问题;出现错误,因为 alias.cer 文件已添加到存储中。我看不到任何参数来解决插件中的问题。有 'skip' 和 'skipIfExist' 参数。这些参数不是为了这个目的; skip 禁用插件,skipIfExist 如果商店已经存在则跳过。
我该如何解决这个问题?或者你知道这个目标的替代插件吗?
我意识到这个插件是在 java keytool 的基础上开发的。 keytool 中没有用于 'skip if certificate is already exist' 目的的任何参数。因此,我使用 'skip' 参数来处理这个问题,方法是添加一个在构建项目时使用的自定义参数。
<properties>
<cert.skip>true</cert.skip>
</properties>
<plugin>
<!-- https://mvnrepository.com/artifact/org.codehaus.mojo/keytool-maven-plugin -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>importCertificate</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<configuration>
<skip>${cert.skip}</skip>
<keystore>${JAVA_HOME}/lib/security/cacerts</keystore>
<storepass>changeit</storepass>
<alias>alias</alias>
<file>${basedir}/src/main/resources/alias.cer</file>
<noprompt>true</noprompt>
</configuration>
</plugin>
用法: mvn clean install -Dcert.skip=false