Set the android.manifest.versionCode as a maven property #115

Merged
merged 3 commits into from May 1, 2012

Conversation

Projects
None yet
3 participants
@quiffman
Contributor

quiffman commented Apr 26, 2012

I was trying to find a way to use the <versionCodeAutoIncrement> option and get the resulting versionCode out for use later in the build process.

Specifically, I was trying to use maven-resources-plugin to filter a json file with name, versionName and versionCode for use with HockeyKit.

It's entirely possible I've missed something but this seemed like the simplest way to accomplish that goal and I thought it might be of use to others.

@mosabua

This comment has been minimized.

Show comment Hide comment
@mosabua

mosabua Apr 26, 2012

Owner

Sounds good. How about for consistencies sake also exposing the other changed properties (at least the version ones) and updating the javadoc for the config parameters to reflect that property export with the full property names so we have some sort of documentation beyond the source code?

Owner

mosabua commented Apr 26, 2012

Sounds good. How about for consistencies sake also exposing the other changed properties (at least the version ones) and updating the javadoc for the config parameters to reflect that property export with the full property names so we have some sort of documentation beyond the source code?

@quiffman

This comment has been minimized.

Show comment Hide comment
@quiffman

quiffman Apr 27, 2012

Contributor

Yup, good plan. My initial pull request was trying to sound-out whether this was a good idea...

I've added some javadoc and exposed versionName, versionCode, versionCodeAutoIncrement, versionCodeUpdateFromVersion, debuggable and sharedUserId.

Contributor

quiffman commented Apr 27, 2012

Yup, good plan. My initial pull request was trying to sound-out whether this was a good idea...

I've added some javadoc and exposed versionName, versionCode, versionCodeAutoIncrement, versionCodeUpdateFromVersion, debuggable and sharedUserId.

mosabua added a commit that referenced this pull request May 1, 2012

Merge pull request #115 from quiffman/master
Set the android.manifest.versionCode as a maven property

@mosabua mosabua merged commit 4654bfe into simpligility:master May 1, 2012

@tprochazka

This comment has been minimized.

Show comment Hide comment
@tprochazka

tprochazka Aug 13, 2012

Contributor

Maybe will be usefull add the example how to use it directly in the plugin configuration section:

<configuration>
  <manifestVersionCodeAutoIncrement>true</manifestVersionCodeAutoIncrement>
  or
  <manifestVersionCodeUpdateFromVersion>true</manifestVersionCodeUpdateFromVersion>
<configuration>

I use different solution. I have android:versionCode set to the "0". My application automatically detect it as testing mode and when I build it in the release mode it replace dev with SVN revision number or by commits count in GIT.

I use buildnumber plugin and replacer with this configuration:

            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>replacer</artifactId>
                <version>1.5.0</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <file>./AndroidManifest.xml</file>
                    <outputFile>${project.build.directory}/AndroidManifest.xml</outputFile>
                    <regex>true</regex>
                    <replacements>
                        <replacement>
                            <token>android:versionCode="\d*"</token>
                            <value>android:versionCode="${buildNumber}"</value>
                        </replacement>
                        <replacement>
                            <token>android:versionName="[^"]*"</token>
                            <value>android:versionName="${project.version}"</value>
                        </replacement>
                        <replacement>
                            <token>-SNAPSHOT"</token>
                            <value>-${buildNumber}"</value>
                        </replacement>
                    </replacements>
                </configuration>
            </plugin>

and in android plugin configuration I have this <androidManifestFile>${project.build.directory}/AndroidManifest.xml</androidManifestFile>

It provide really unique versionCode which does not depend who or where build the project.
Only problem is that buildnumber can do support this http://jira.codehaus.org/browse/MBUILDNUM-93 now, so I must use own forked version which contain this patch.

Contributor

tprochazka commented Aug 13, 2012

Maybe will be usefull add the example how to use it directly in the plugin configuration section:

<configuration>
  <manifestVersionCodeAutoIncrement>true</manifestVersionCodeAutoIncrement>
  or
  <manifestVersionCodeUpdateFromVersion>true</manifestVersionCodeUpdateFromVersion>
<configuration>

I use different solution. I have android:versionCode set to the "0". My application automatically detect it as testing mode and when I build it in the release mode it replace dev with SVN revision number or by commits count in GIT.

I use buildnumber plugin and replacer with this configuration:

            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>replacer</artifactId>
                <version>1.5.0</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <file>./AndroidManifest.xml</file>
                    <outputFile>${project.build.directory}/AndroidManifest.xml</outputFile>
                    <regex>true</regex>
                    <replacements>
                        <replacement>
                            <token>android:versionCode="\d*"</token>
                            <value>android:versionCode="${buildNumber}"</value>
                        </replacement>
                        <replacement>
                            <token>android:versionName="[^"]*"</token>
                            <value>android:versionName="${project.version}"</value>
                        </replacement>
                        <replacement>
                            <token>-SNAPSHOT"</token>
                            <value>-${buildNumber}"</value>
                        </replacement>
                    </replacements>
                </configuration>
            </plugin>

and in android plugin configuration I have this <androidManifestFile>${project.build.directory}/AndroidManifest.xml</androidManifestFile>

It provide really unique versionCode which does not depend who or where build the project.
Only problem is that buildnumber can do support this http://jira.codehaus.org/browse/MBUILDNUM-93 now, so I must use own forked version which contain this patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment