原因:
运行mvn clean install -X
原因 Maven在构建生命周期default-install
结束时执行目标,它使用默认的 groupId:artifactId:packaging:version 安装生成的 apk(我在此示例中用作最终名称):abc-123
[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] ... ...
解决方案:
此默认工件安装是 AFAIK 既不可避免也不可修改,并且在默认安装目标执行期间<finalName>
不会对目标文件名(使用固定模式)产生任何影响。artifactId-version-classifier.packaging
解决方案是在构建生命周期中附加额外的工件,取决于您的需求(如果您只需要在后面添加一些后缀),最简单的方法是在 android-maven-plugin 配置myapp-1.2.2-SNAPSHOT
中定义一个分类器:
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<classifier>test</classifier>
... ...
</configuration>
</plugin>
这将导致 myapp-1.2.2-SNAPSHOT.apk 和 myapp-1.2.2-SNAPSHOT-test.apk 都安装到 maven 存储库中:
[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