Reason:
Running mvn clean install -X
cause Maven execute default-install
goal at the end of the build life cycle, which use the default groupId:artifactId:packaging:version install the generated apk (I use abc-123
as the final name in this example):
[INFO] --- maven-install-plugin:2.1:install (default-install) @ myapp ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-install-plugin:2.1:install from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-install-plugin:2.1, parent: sun.misc.Launcher$AppClassLoader@11b86e7]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-install-plugin:2.1:install' with basic configurator -->
[DEBUG] (f) artifact = com.mycompany:myapp:apk:1.2.2-SNAPSHOT
[DEBUG] (f) attachedArtifacts = [com.mycompany:myapp:jar:1.2.2-SNAPSHOT]
[DEBUG] ... ...
[DEBUG] -- end configuration --
[INFO] Installing C:\workspace\myapp\target\abc-123.apk to c:\maven\repository\com\mycompany\myapp\1.2.2-SNAPSHOT\myapp-1.2.2-SNAPSHOT.apk
[INFO] ... ...
Solution:
This default artifact install is AFAIK neither avoidable nor modifiable, and the <finalName>
doesn't take any effect on the target file name (which use a fixed pattern artifactId-version-classifier.packaging
) during the default-install goal execution. The solution is attach extra artifact to the build life cycle, depend on you demand (If you only need add some suffix behind myapp-1.2.2-SNAPSHOT
), the easiest way is define a classifier in android-maven-plugin configuration:
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<classifier>test</classifier>
... ...
</configuration>
</plugin>
This will cause both myapp-1.2.2-SNAPSHOT.apk and myapp-1.2.2-SNAPSHOT-test.apk get installed into maven repository:
[INFO] --- maven-install-plugin:2.1:install (default-install) @ myapp ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-install-plugin:2.1:install from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-install-plugin:2.1, parent: sun.misc.Launcher$AppClassLoader@11b86e7]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-install-plugin:2.1:install' with basic configurator -->
[DEBUG] (f) artifact = com.mycompany:myapp:apk:1.2.2-SNAPSHOT
[DEBUG] (f) attachedArtifacts = [com.mycompany:myapp:jar:1.2.2-SNAPSHOT, com.mycompany:myapp:apk:test:1.2.2-SNAPSHOT]
[DEBUG] ... ...
[DEBUG] -- end configuration --
[INFO] Installing C:\workspace\myapp\target\abc-123.jar to c:\maven\repository\com\mycompany\myapp\1.2.2-SNAPSHOT\myapp-1.2.2-SNAPSHOT.apk
[INFO] ... ...
[INFO] Installing C:\workspace\myapp\target\abc-123.apk to c:\maven\repository\com\mycompany\myapp\1.2.2-SNAPSHOT\myapp-1.2.2-SNAPSHOT-test.apk