I have tried to use properties file to read properties to set those values into apk while building using maven.
Pluging i have used
->>>>>>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/buildNumber.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<build>
<sourceDirectory>src</sourceDirectory>
<finalName>myapk.${majorversion}.${minor_version}.${patch_version}.${maven.build.timestamp}</finalName>
File: buildNumber.properties
major_version=01
minor_version=00
patch_version=00
This generating myapk.01.00.00.20120127-2010.jar but apk is myapk.${major_version}.a.${minor_version}.${patch_version}.20120127-2010.apk
Let me know what I am missing here..?
I don’t know the exact reason, but it looks like properties-maven-plugin can substitute the property value properly defined under properties tag in pom.xml, and maven can only recognize the properties name explicitly defined in pom.xml, the following pom works for me:
EDIT:
From my point of view, The predefined build lifecycle of maven is quite exclusive especially when integrating with other build tools like ADT, the pom version used for generating the apk is quite restricted, moreover, from the plugin documentation, current version of android-maven-plugin does not provide any configuration for customizing the final apk name during apk goal. A similar discussion was posted here end up with a not so perfect answer.
As a last shot, android-maven-plugin provide options to customize the final apk name during zipalign goal:
This could be a solution if you use maven zipalign your final apk (I suppose you do), you will get all three output files (.ap_ and .apk and .jar) end with the default ${project.version} plus another apk end with ${major_version}-aligned, however only those three with the default ${project.version} will get installed in the maven central repository.