1

In my maven build, I'd like to execute the proguard goal after the tests, in order to get test result faster. Therefore, I tried to bind it to prepare-package phase. However, my config bellow does not have any effect. The proguard goal is still executed in process-classes phase (default-proguard). What am I missing?

<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>
schnatterer
  • 7,525
  • 7
  • 61
  • 80

1 Answers1

3

Old answer:

You can not change the phase proguard runs. But typically you can isolate into a profile to only run when needed and not with each build. The typical use case would be a release profile that you only run for releases. You could also make it part of a QA profile and use that for development builds that need to be verified beyond the normal usage during development.

Update after some thinking:

You can change the proguard mojo execution to a different phase by having two executions configured. One for the process-sources phase as originally configured inside the Android Maven Plugin set to be skipped. Then the second execution is configured for the desired phase with skip set to 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>
schnatterer
  • 7,525
  • 7
  • 61
  • 80
Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
  • I was afraid you'd say that it's not possible, as I saw this solution on [the examples](https://github.com/simpligility/android-maven-plugin/blob/2242c00c382bb298ad88f8a365cb7193e4b26af5/src/test/projects/morseflash/morseflash-app/pom.xml#L108). Thanks for making this clear, though! – schnatterer Mar 07 '15 at 12:29
  • 1
    @schnatterer I think you might be able to do it after all. You would have to configure two executions. One set to skip that overrides the one built into the plugin and another that adds the new execution. I have not tested this but it might work. – Manfred Moser Mar 10 '15 at 17:11
  • Nice idea and it actually works! Could you post this as a separate answer? I'd rather mark that answer as accepted one ;-) I can fill in the XML that worked for me in your answer – schnatterer Apr 08 '15 at 08:48