我创建了一个 Android Maven 项目,正如本文所述(链接到文章)。我使用最后一个原型:android-release。
所以一切正常,除了我想发布一个版本时,我不知道如何传递证书属性。我创建了一个包含以下内容的 settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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-debug</id>
<properties>
<sign.keystore>/Users/me/.android/debug.keystore</sign.keystore>
<sign.alias>androiddebugkey</sign.alias>
<sign.storepass>android</sign.storepass>
<sign.keypass>android</sign.keypass>
</properties>
</profile>
<profile>
<id>android-release</id>
<properties>
<sign.keystore>/Users/me/myKeystore.keystore</sign.keystore>
<sign.alias>myAlias</sign.alias>
<sign.storepass><![CDATA[myPassword]]></sign.storepass>
<sign.keypass><![CDATA[myPassword]]></sign.keypass>
</properties>
</profile>
</profiles>
然后我运行:
mvn -s setttings.xml clean release:prepare release:perform -Pandroid-release
但我一直忽略 android-release 配置文件中定义的值。
任何想法如何让这个工作?当我刚刚运行时:
mvn -s setttings.xml clean install -Pandroid-release,release
它构建一个 apk 并使用正确的证书对其进行签名。所以也许它只是 maven-enforcer-plugin,它无法从 settings.xml 中读取属性?