我已经使用android-release 原型生成了我的项目。
在其文档中表明要在文件中添加android-release
配置settings.xml
文件。
我的~/.m2/settings.xml
样子是这样的:
<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)生成的相同:
<?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
,它似乎找不到有关要使用的密钥库的信息:
[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
mvn release:perform -Dsign.keystore=/path/to/keystore \
-Dsign.alias=key-alias \
-Dsign.storepass=keystore-password \
-Dsign.keypass=key-password
但是效果一样。
关于如何使它起作用的任何想法?这可能很愚蠢,但我是 Maven 的初学者,我无法弄清楚。