android-maven-plugin: 将混淆器绑定到后期

android-maven-plugin: Binding proguard to later phase

在我的 Maven 构建中,我想执行 proguard goal after the tests,以便更快地获得测试结果。因此,我试图将它绑定到 prepare-package 阶段。但是,我的配置波纹管没有任何效果。 proguard 目标仍然在 process-classes 阶段执行(default-proguard)。我错过了什么?

<plugin>
    <groupId>com.simpligility.maven.plugins</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>4.1.0</version>
    <executions>
        <execution>
            <id>progurad-after-test</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>proguard</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <!-- ... -->
        <proguard>
            <skip>false</skip>
        </proguard>
    </configuration>
</plugin>

旧答案:

您不能更改阶段混淆器 运行s。但通常您可以在需要时将配置文件隔离到 运行,而不是每次构建。典型的用例是发布配置文件,您只 运行 发布。您还可以将其作为 QA 配置文件的一部分,并将其用于需要在开发过程中超出正常使用范围进行验证的开发版本。

思考后更新:

您可以通过配置两个执行来将 proguard mojo 执行更改为不同的阶段。一个用于 process-sources 阶段,最初配置在 Android Maven 插件设置被跳过。然后为所需阶段配置第二次执行,并将 skip 设置为 false。

<plugin>
    <groupId>com.simpligility.maven.plugins</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>4.1.0</version>
    <executions>
        <execution>
            <!-- Skip proguard in the default phase (process-classes)... -->
            <id>override-default</id>
            <configuration>
                <proguard>
                    <skip>true</skip>
                </proguard>
            </configuration>
        </execution>
        <execution>
            <!-- But execute proguard after running the tests
                 Bind to test phase so proguard runs before dexing (prepare package phase)-->
            <id>progurad-after-test</id>
            <phase>test</phase>
            <goals>
                <goal>proguard</goal>
            </goals>
            <configuration>
                <proguard>
                    <skip>false</skip>
                </proguard>
            </configuration>
        </execution>
    </executions>
    <configuration>
        <!-- Other configuration goes here. -->
    </configuration>
</plugin>