maven-jarsigner 在构建期间不执行

maven-jarsigner not executing during build

各位。我正在尝试使用 Maven Jarsigner 签署 Android APK。我按照 maven-jarsigner 站点上的说明进行操作,并告诉它使用我自己的密钥库并进行验证。它看起来不像 jarsigner 插件甚至 运行 来自我的 pom.xml,更不用说验证了。我现在正在使用 Codenvy 作为我的环境,因此我无法使用 Maven 控制台命令。任何帮助,将不胜感激。这是我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.kealinghornets.mapsapplication</groupId>
<artifactId>mobile-android-java-basic</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>MapsApp</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <platform.version>4.1.1.4</platform.version>
    <android.plugin.version>3.8.0</android.plugin.version>
    <android.sdk.platform.version>20</android.sdk.platform.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>${platform.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>support-v4</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>com.jdroidframework</groupId>
        <artifactId>google-play-services</artifactId>
        <type>apklib</type>
        <version>LATEST</version>
    </dependency>
</dependencies>
<build>
    <sourceDirectory>java</sourceDirectory>
    <finalName>${project.artifactId}</finalName>
    <defaultGoal>install</defaultGoal>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jarsigner-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <id>sign</id>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>                       
                    <execution>
                        <id>verify</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                     <keystore>${project.basedir}/mapsapp.keystore</keystore>
                     <storepass>maps_app</storepass>
                     <keypass>maps_app</keypass>
                     <alias>maps_app</alias>
                     <verbose>true</verbose>
                     <certs>true</certs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>${android.plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <sign>
                        <debug>false</debug>
                    </sign>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <sdk>
                    <platform>${android.sdk.platform.version}</platform>
                </sdk>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

这是我的构建的 Maven 输出:

[INFO] Injecting source code into builder...
[INFO] Source code injection finished
[INFO] ------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building MapsApp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ mobile-android-java-basic ---
[INFO] 
[INFO] --- android-maven-plugin:3.8.0:generate-sources (default-generate-sources) @ mobile-android-java-basic ---
[DEBUG] Expanding: /home/codenvy/.m2/repository/com/jdroidframework/google-play-services/0.6.0/google-play-services-0.6.0.apklib into /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0
[DEBUG] expand complete
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Manifest merging disabled. Using project manifest only
[INFO] /usr/local/android-sdk-linux/build-tools/21.1.1/aapt [package, -m, -J, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/generated-sources/r, -M, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/AndroidManifest.xml, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/res, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/res, --auto-add-overlay, -I, /usr/local/android-sdk-linux/platforms/android-20/android.jar]
[INFO] /usr/local/android-sdk-linux/build-tools/21.1.1/aapt [package, --non-constant-id, -m, -J, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/generated-sources/r, --custom-package, com.google.android.gms, -M, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/AndroidManifest.xml, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/res, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/res, --auto-add-overlay, -I, /usr/local/android-sdk-linux/platforms/android-20/android.jar]
[INFO] 
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ mobile-android-java-basic ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/src/main/resources
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/generated-sources/extracted-dependencies/src/main/resources
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/src
[INFO] 
[INFO] --- android-maven-plugin:3.8.0:consume-aar (default-consume-aar) @ mobile-android-java-basic ---
[INFO] 
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ mobile-android-java-basic ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/classes
[INFO] 
[INFO] --- android-maven-plugin:3.8.0:proguard (default-proguard) @ mobile-android-java-basic ---
[INFO] 
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ mobile-android-java-basic ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ mobile-android-java-basic ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ mobile-android-java-basic ---
[INFO] No tests to run.
[INFO] 
[INFO] --- android-maven-plugin:3.8.0:emma (default-emma) @ mobile-android-java-basic ---
[INFO] 
[INFO] --- android-maven-plugin:3.8.0:dex (default-dex) @ mobile-android-java-basic ---
[INFO] /usr/local/jdk1.7.0_71/jre/bin/java [-Xmx1024M, -jar, /usr/local/android-sdk-linux/build-tools/21.1.1/lib/dx.jar, --dex, --output=/media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/classes.dex, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/classes, /home/codenvy/.m2/repository/com/jdroidframework/google-play-services/0.6.0/google-play-services-0.6.0.apklib, /home/codenvy/.m2/repository/android/google-play-services/r21/google-play-services-r21.jar, /home/codenvy/.m2/repository/com/google/android/support-v4/r7/support-v4-r7.jar]
[INFO] 
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ mobile-android-java-basic ---
[INFO] Building jar: /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.jar
[INFO] 
[INFO] --- android-maven-plugin:3.8.0:apk (default-apk) @ mobile-android-java-basic ---
[INFO] Enabling debug build for apk.
[INFO] /usr/local/android-sdk-linux/build-tools/21.1.1/aapt [package, -f, -M, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/AndroidManifest.xml, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/res, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/res, --auto-add-overlay, -I, /usr/local/android-sdk-linux/platforms/android-20/android.jar, -F, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.ap_, --debug-mode]
[INFO] 
[INFO] --- android-maven-plugin:3.8.0:internal-pre-integration-test (default-internal-pre-integration-test) @ mobile-android-java-basic ---
[INFO] No InstrumentationRunner found - skipping tests
[INFO] 
[INFO] --- android-maven-plugin:3.8.0:internal-integration-test (default-internal-integration-test) @ mobile-android-java-basic ---
[INFO] No InstrumentationRunner found - skipping tests
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ mobile-android-java-basic ---
[INFO] Installing /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.apk to /home/codenvy/.m2/repository/org/kealinghornets/mapsapplication/mobile-android-java-basic/1.0-SNAPSHOT/mobile-android-java-basic-1.0-SNAPSHOT.apk
[INFO] Installing /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/pom.xml to /home/codenvy/.m2/repository/org/kealinghornets/mapsapplication/mobile-android-java-basic/1.0-SNAPSHOT/mobile-android-java-basic-1.0-SNAPSHOT.pom
[INFO] Installing /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.jar to /home/codenvy/.m2/repository/org/kealinghornets/mapsapplication/mobile-android-java-basic/1.0-SNAPSHOT/mobile-android-java-basic-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.161s
[INFO] Finished at: Thu Feb 26 19:57:09 UTC 2015
[INFO] Final Memory: 22M/398M
[INFO] ------------------------------------------------------------------------
[INFO] Project androidmaps successfully build

maven-jarsigner-plugin是在pluginManagement段内声明的,所以不会执行。 pluginManagement 只应该用于考虑不同 Maven 模块的插件配置。

请注意,android-maven-plugin 实际上已执行,因为它也在 plugins 部分中声明,因此它继承了 pluginManagement 中的声明。

您应该将 maven-jarsigner-plugin 代码移动到 plugins 部分。