-1

I use maven to package my app. Now I want integrate leakcanary only in debug version. So I need to add a <dependency> node to my pom.xml. But I want to remove it from release version. How Can I do that? I have a solution that a pom.xml for debug version and another pom for release version. Another solution is use shell to modify pom.xml before package. Any better idea?

maven:3.3.9
com.simpligility.maven.plugins:android-maven-plugin:4.4.3

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
android_su
  • 1,637
  • 4
  • 21
  • 30

1 Answers1

0

You can do that with Maven profiles; they can host several POM elements: property values, configurations, dependencies, etc.
You then enable one of more of these profiles with -P when running from the command line, or e.g. in Eclipse, with the specific entry in the Run as... window.

Here's a brief example:

    <!-- Dependencies declarations -->
</dependencies>

<profiles>
    <profile>
        <id>extralib</id>
        <properties>
            <!-- specify property values here -->
        </properties>

        <dependencies>
        <dependency>
            <!-- add dependency decl here -->
        <dependency>
        </dependencies>
    </profile>

<!-- you may have several profiles -->

All of the childs of <profile> are optional.

watery
  • 5,026
  • 9
  • 52
  • 92