Reputation: 5577
I created an Android Maven project just as described in this post (link to post). I use the last archetype: android-release.
So everything is working fine, except when I want to release a version, I can not figure out how to pass the certificate properties. I created an settings.xml with the following content:
<?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>
Then I run:
mvn -s setttings.xml clean release:prepare release:perform -Pandroid-release
But I keeps ignoring the values defined in the android-release profile.
Any ideas how to get this working? When I just run:
mvn -s setttings.xml clean install -Pandroid-release,release
it builds an apk and signes it with the right certificate. So maybe it's just the maven-enforcer-plugin, which is not able to read the properties from the settings.xml?
Upvotes: 1
Views: 2482
Reputation: 41126
mvn -s setttings.xml clean release:prepare release:perform -Pandroid-release
I don't know the answer why it keeps ignoring the values defined in the android-release profile.
However, if you use maven-release-plugin, the normal way we used to achieve what you want is add the following settings to the profile which you want to trigger at release phase:
<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>
<!-- via this activation the profile is automatically used when the release
is done with the maven release plugin -->
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
</profile>
So now if you do mvn -s setttings.xml clean release:prepare release:perform
, maven-release-plugin will automatically pick up profile android-release
.
Note that the profile is automatically activated at release phase, if there is no maven-release-plugin involved, you can still use the classic way mvn -s setttings.xml clean install -Pandroid-release
to make build process use the specific profile android-release
.
Check out maven-release-plugin doc for more details.
Upvotes: 2