Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #115 from quiffman/master

Set the android.manifest.versionCode as a maven property
  • Loading branch information...
commit 4654bfefe2a05258881fbbd2a52fbb3144d31cd3 2 parents 9923959 + 43e4687
@mosabua mosabua authored
View
32 src/main/java/com/jayway/maven/plugins/android/standalonemojos/ManifestUpdateMojo.java
@@ -149,21 +149,25 @@
/**
* Update the <code>android:versionName</code> with the specified parameter. If left empty it
- * will use the version number of the project.
+ * will use the version number of the project. Exposed via the project property
+ * <code>android.manifest.versionName</code>.
*
* @parameter expression="${android.manifest.versionName}" default-value="${project.version}"
*/
protected String manifestVersionName;
/**
- * Update the <code>android:versionCode</code> attribute with the specified parameter.
+ * Update the <code>android:versionCode</code> attribute with the specified parameter. Exposed via
+ * the project property <code>android.manifest.versionCode</code>.
*
* @parameter expression="${android.manifest.versionCode}"
*/
protected Integer manifestVersionCode;
/**
- * Auto increment the <code>android:versionCode</code> attribute with each build.
+ * Auto increment the <code>android:versionCode</code> attribute with each build. The value is
+ * exposed via the project property <code>android.manifest.versionCodeAutoIncrement</code> and
+ * the resulting value as <code>android.manifest.versionCode</code>.
*
* @parameter expression="${android.manifest.versionCodeAutoIncrement}" default-value="false"
*/
@@ -173,21 +177,25 @@
* Update the <code>android:versionCode</code> attribute automatically from the project version
* e.g 3.0.1 will become version code 301. As described in this blog post
* http://www.simpligility.com/2010/11/release-version-management-for-your-android-application/
- * but done without using resource filtering.
+ * but done without using resource filtering. The value is exposed via the project property
+ * property <code>android.manifest.versionCodeUpdateFromVersion</code> and the resulting value
+ * as <code>android.manifest.versionCode</code>.
*
* @parameter expression="${android.manifest.versionCodeUpdateFromVersion}" default-value="false"
*/
protected Boolean manifestVersionCodeUpdateFromVersion = false;
/**
- * Update the <code>android:sharedUserId</code> attribute with the specified parameter.
+ * Update the <code>android:sharedUserId</code> attribute with the specified parameter. If
+ * specified, exposes the project property <code>android.manifest.sharedUserId</code>.
*
* @parameter expression="${android.manifest.sharedUserId}"
*/
protected String manifestSharedUserId;
/**
- * Update the <code>android:debuggable</code> attribute with the specified parameter.
+ * Update the <code>android:debuggable</code> attribute with the specified parameter. Exposed via
+ * the project property <code>android.manifest.debuggable</code>.
*
* @parameter expression="${android.manifest.debuggable}"
*/
@@ -362,6 +370,15 @@ public void updateManifest(File manifestFile) throws IOException, ParserConfigur
"Please specify either versionCodeAutoIncrement, versionCodeUpdateFromVersion or versionCode!");
}
+ // Expose the version properties and other simple parsed manifest entries
+ project.getProperties().setProperty("android.manifest.versionName", parsedVersionName);
+ project.getProperties().setProperty("android.manifest.versionCodeAutoIncrement", String.valueOf(parsedVersionCodeAutoIncrement));
+ project.getProperties().setProperty("android.manifest.versionCodeUpdateFromVersion", String.valueOf(parsedVersionCodeUpdateFromVersion));
+ project.getProperties().setProperty("android.manifest.debuggable", String.valueOf(parsedDebuggable));
+ if (parsedSharedUserId != null) {
+ project.getProperties().setProperty("android.manifest.sharedUserId", parsedSharedUserId);
+ }
+
if (parsedVersionCodeAutoIncrement) {
Attr versionCode = manifestElement.getAttributeNode(ATTR_VERSION_CODE);
int currentVersionCode = 0;
@@ -370,6 +387,7 @@ public void updateManifest(File manifestFile) throws IOException, ParserConfigur
}
currentVersionCode++;
manifestElement.setAttribute(ATTR_VERSION_CODE, String.valueOf(currentVersionCode));
+ project.getProperties().setProperty("android.manifest.versionCode", String.valueOf(currentVersionCode));
dirty = true;
}
@@ -382,6 +400,7 @@ public void updateManifest(File manifestFile) throws IOException, ParserConfigur
Integer.toString(artifactVersion.getIncrementalVersion());
getLog().info("Setting " + ATTR_VERSION_CODE + " to " + verCode);
manifestElement.setAttribute(ATTR_VERSION_CODE, verCode);
+ project.getProperties().setProperty("android.manifest.versionCode", String.valueOf(verCode));
dirty = true;
}
@@ -396,6 +415,7 @@ public void updateManifest(File manifestFile) throws IOException, ParserConfigur
manifestElement.setAttribute(ATTR_VERSION_CODE, String.valueOf(parsedVersionCode));
dirty = true;
}
+ project.getProperties().setProperty("android.manifest.versionCode", String.valueOf(parsedVersionCode));
}
if (!StringUtils.isEmpty(parsedSharedUserId)) {
Please sign in to comment.
Something went wrong with that request. Please try again.