首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Maven版本:perform无法识别密钥库参数

Maven版本:perform无法识别密钥库参数
EN

Stack Overflow用户
提问于 2013-02-01 04:45:16
回答 2查看 2.6K关注 0票数 3

我已经使用android-release archetype生成了我的项目。

在其文档中指示在settings.xml文件中添加android-release配置文件。

我的~/.m2/settings.xml看起来像这样:

代码语言:javascript
复制
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
  http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>   
    <profile>
      <id>android-release</id>
        <properties>
            <sign.keystore>absolute path</sign.keystore>
            <sign.alias>my_alias</sign.alias>
            <sign.storepass>pass</sign.storepass>
            <sign.keypass>pass</sign.keypass>
        </properties>
    </profile>
  </profiles>
</settings>

我的父pom.xml文件与原型(1.0.8版)生成的文件几乎相同:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
  http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>myapp-android</groupId>
    <artifactId>myapp-android-parent</artifactId>
    <version>1.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>myapp-android - Parent</name>

    <modules>
        <module>myapp-android</module>
        <module>myapp-android-it</module>
    </modules>

    <scm>
        <url>....</url>
        <connection>....</connection>
        <developerConnection>....</developerConnection>
        <tag>HEAD</tag>
    </scm>

    <properties>
        <platform.version>4.1.1.4</platform.version>
        <android.dex.optimize>false</android.dex.optimize>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <repositories>
        <repository>
            <id>ignition-releases</id>
            <url>http://nexus.qype.com/content/repositories/releases</url>
        </repository>
        <repository>
            <id>central</id>
            <url>http://repo1.maven.org/maven2</url>
        </repository>
        <repository>
            <id>com.jakewharton</id>
            <url>http://r.jakewharton.com/maven/release</url>
        </repository>
    </repositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.google.android</groupId>
                <artifactId>android</artifactId>
                <version>${platform.version}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.google.android</groupId>
                <artifactId>android-test</artifactId>
                <version>${platform.version}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.10</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.5.0</version>
                    <inherited>true</inherited>
                    <configuration>
                        <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                        <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                        <resourceDirectory>${project.basedir}/res</resourceDirectory>
                        <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
                        <sdk>
                            <platform>16</platform>
                        </sdk>
                        <undeployBeforeDeploy>false</undeployBeforeDeploy>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5.1</version>
                    <inherited>true</inherited>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>1.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.3</version>
                    <configuration>
                        <autoVersionSubmodules>true</autoVersionSubmodules>
                        <!-- We need this since our pom.xml is not inside repo root -->
                        <arguments>-f ./android/pom.xml</arguments>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-jarsigner-plugin</artifactId>
                    <version>1.2</version>
                    <inherited>true</inherited>
                    <configuration>
                        <removeExistingSignatures>true</removeExistingSignatures>
                        <archiveDirectory />
                        <archive>${project.build.directory}/${project.build.finalName}.${project.packaging}</archive>
                        <verbose>true</verbose>
                        <certs>true</certs>
                        <keystore>${sign.keystore}</keystore>
                        <alias>${sign.alias}</alias>
                        <storepass>${sign.storepass}</storepass>
                        <keypass>${sign.keypass}</keypass>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.pyx4me</groupId>
                    <artifactId>proguard-maven-plugin</artifactId>
                    <version>2.0.4</version>
                    <dependencies>
                        <dependency>
                            <groupId>net.sf.proguard</groupId>
                            <artifactId>proguard</artifactId>
                            <version>4.4</version>
                            <scope>runtime</scope>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <proguardVersion>4.4</proguardVersion>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                        <artifactId>android-maven-plugin</artifactId>
                        <version>3.5.0</version>
                        <configuration>
                            <release>true</release>
                        </configuration>
                    </plugin>

                    <plugin>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>enforce-signing-properties</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireProperty>
                                            <property>sign.keystore</property>
                                            <message>The 'sign.keystore' property is missing. It must contain the path to the
                                                keystore used to sign the application.
                                            </message>
                                        </requireProperty>
                                        <requireFilesExist>
                                            <files>
                                                <file>${sign.keystore}</file>
                                            </files>
                                            <message>The 'sign.keystore' property does not point to a file. It must contain the
                                                path to the keystore used to sign the application.
                                            </message>
                                        </requireFilesExist>
                                        <requireProperty>
                                            <property>sign.alias</property>
                                            <message>The 'sign.alias' property is missing. It must contain the key alias used to
                                                sign the application.
                                            </message>
                                        </requireProperty>
                                        <requireProperty>
                                            <property>sign.storepass</property>
                                            <message>The 'sign.storepass' property is missing. It must contain the password of
                                                the keystore used to sign the application.
                                            </message>
                                        </requireProperty>
                                        <requireProperty>
                                            <property>sign.keypass</property>
                                            <message>The 'sign.keypass' property is missing. It must contain the password of the
                                                key used to sign the application.
                                            </message>
                                        </requireProperty>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>linux</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <rt.jar.path>${java.home}/jre/lib/rt.jar</rt.jar.path>
                <jsse.jar.path>${java.home}/jre/lib/jsse.jar</jsse.jar.path>
            </properties>
        </profile>
        <!-- mac profile has to be after unix since running on mac will trigger both -->
        <profile>
            <id>mac</id>
            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>
            <properties>
                <!-- absolute path -->
                <!--<rt.jar.path>/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar</rt.jar.path> -->
                <!-- or with JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/ -->
                <rt.jar.path>${java.home}/../Classes/classes.jar</rt.jar.path>
                <jsse.jar.path>${java.home}/../Classes/jsse.jar</jsse.jar.path>
            </properties>
        </profile>
        <profile>
            <id>windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <rt.jar.path>${java.home}/jre/lib/rt.jar</rt.jar.path>
                <jsse.jar.path>${java.home}/jre/lib/jsse.jar</jsse.jar.path>
            </properties>
        </profile>
    </profiles>

</project>

当我运行mvn release:perform时,它似乎找不到要使用的密钥库的相关信息:

代码语言:javascript
复制
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building myapp-android - Parent 1.0
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-signing-properties) @ myapp-android-parent ---
[INFO] [WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
[INFO] The 'sign.keystore' property is missing. It must contain the path to the
[INFO]                                                 keystore used to sign the application.
[INFO] [WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireFilesExist failed with message:
[INFO] The 'sign.keystore' property does not point to a file. It must contain the
[INFO]                                                 path to the keystore used to sign the application.
[INFO] Some required files are missing:
[INFO] (an empty filename was given and allowNulls is false)
[INFO] 
[INFO] [WARNING] Rule 2: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
[INFO] The 'sign.alias' property is missing. It must contain the key alias used to
[INFO]                                                 sign the application.
[INFO] [WARNING] Rule 3: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
[INFO] The 'sign.storepass' property is missing. It must contain the password of
[INFO]                                                 the keystore used to sign the application.
[INFO] [WARNING] Rule 4: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
[INFO] The 'sign.keypass' property is missing. It must contain the password of the
[INFO]                                                 key used to sign the application.
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary:
[INFO] [INFO] 
[INFO] [INFO] myapp-android - Parent ......................... FAILURE [0.577s]
[INFO] [INFO] myapp-android - Application .................... SKIPPED
[INFO] [INFO] myapp-android-it - Integration tests ........... SKIPPED
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 1.862s
[INFO] [INFO] Finished at: Thu Jan 31 21:24:41 CET 2013
[INFO] [INFO] Final Memory: 7M/81M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.0:enforce (enforce-signing-properties) on project myapp-android-parent: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[INFO] [ERROR] 
[INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[INFO] [ERROR] 
[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] myapp-android - Parent ......................... FAILURE [22.389s]
[INFO] myapp-android - Application .................... SKIPPED
[INFO] myapp-android-it - Integration tests ........... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.799s
[INFO] Finished at: Thu Jan 31 21:24:41 CET 2013
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3:perform (default-cli) on project myapp-android-parent: Maven execution failed, exit code: '1' -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我还尝试将密钥库参数传递给release:perform

代码语言:javascript
复制
mvn release:perform -Dsign.keystore=/path/to/keystore \
                    -Dsign.alias=key-alias \
                    -Dsign.storepass=keystore-password \
                    -Dsign.keypass=key-password

但效果是一样的。

有没有关于如何让它工作的想法?这可能是一些愚蠢的事情,但我是Maven的初学者,我不能理解它。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-02-01 19:44:01

多亏了this discussion,我发现这个问题是由Maven3.0.3的一个bug引起的。升级到Maven 3.0.4完全解决了我的问题。

票数 5
EN

Stack Overflow用户

发布于 2013-02-01 05:35:01

Maven release:perform goal在不同的上下文中执行,并且您的java参数不会被传播。

尝试使用-Darguments选项。例如:mvn release:perform -Darguments="-Dsign.keystore=/path/to/keystore -Dsign.alias=key.alias"

该目标的其他选项可在手册页面上找到:http://maven.apache.org/maven-release/maven-release-plugin/perform-mojo.html

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14634825

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档