理由:
実行中の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