Android: Maven archive final name

At the end of the maven mvn clean install run, the created artifacts are automatically installed in the repository using the maven-install-plugin:

 [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ project --- [INFO] Installing C:\Users\mannaz\workspace\project\target\project-0.1.1-test.apk to C:\Users\mannaz\.m2\repository\at\mannaz\android\project\0.1.1\project-0.1.1.apk [INFO] Installing C:\Users\mannaz\workspace\project\pom.xml to C:\Users\mannaz\.m2\repository\at\mannaz\android\project\0.1.1\project-0.1.1.pom [INFO] Installing C:\Users\mannaz\workspace\project\target\project-0.1.1-test.jar to C:\Users\mannaz\.m2\repository\at\mannaz\android\project\0.1.1\project-0.1.1.jar 

Unfortunately, the final apk file name is renamed during this process ( project-0.1.1-test.apkproject-0.1.1.apk ).

Initially, the apk file name is set via

 <finalName>${project.artifactId}-${project.version}-${webservice.target}</finalName> 

How to specify the final name of the apk file in the assembly archive without overriding the <version/> attribute itself?

+4
source share
1 answer

Cause:

Running mvn clean install -X causes Maven to run the default-install command at the end of the build life cycle , which use the default groupId: artifactId: packaging: version install 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] ... ... 

Decision:

This default setting for AFAIK artifacts is not prohibited or modified, and <finalName> does not affect the name of the target file (which uses the fixed artifactId-version-classifier.packaging template) during the execution of the default installation target. The solution adds an additional artifact to the build life cycle, depending on your demand (if you only need to add a suffix for myapp-1.2.2-SNAPSHOT ), the easiest way is to define a classifier in the 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 myapp-1.2.2-SNAPSHOT.apk and myapp-1.2.2-SNAPSHOT-test.apk to be installed in the 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 
+2
source

Source: https://habr.com/ru/post/1440017/


All Articles