سؤال

During normal development I have a certain build function that needs to be performed. During release that build function needs to be replaced with a release equivalent (in this case Proguarding instead of copying).

I have thought that I might be able to get there using 2 profiles, a DevelopmentProfile and a ReleaseProfile, with the DevelopmentProfile activeByDefault.

Eg

<profiles>
    <profile>
        <id>DevelopmentProfile</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <developmentBuild>true</developmentBuild>
            <releaseBuild>false</releaseBuild>
        </properties>
    </profile>
    <profile>
        <id>ReleaseProfile</id>
        <properties>
            <developmentBuild>false</developmentBuild>
            <releaseBuild>true</releaseBuild>
        </properties>
    </profile>
</profiles>

And have the ReleaseProfile switched on via the release-plugin releaseProfiles attribute and the ReleaseProfile switched off via the releaseProfiles attributes

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <configuration>
        <releaseProfiles>ReleaseProfile,!DevelopmentProfile</releaseProfiles>
    </configuration>
</plugin>

This looked feasible considering this piece on "Deactivating a Profile" http://maven.apache.org/guides/introduction/introduction-to-profiles.html and the fact that the source for the release-plugin just constructs the profiles using the string provided.

But it doesn't seem to work. I suspect because the release-plugin prepends active profiles which probably overrides the profile deactivation.

In any case. Is there another way I can deactivate a profile during release. Or otherwise ensure that only one of these 2 profiles is active at any point.

And I'm not interested in solutions that involve me passing in a system property to explicitly activate a profile as they are not robust enough to survive the workload around here.

هل كانت مفيدة؟

المحلول

OK, everything I have done above is 100% spot on. You can most definitely deactivate a profile during release as I have done above.

The reason it wasn't working for me was because the release-plugin config shown had been specified in a child pom and the parent pom was either overloading the value of releaseProfiles or had taken control altogether.

So moving my config to the parent made everything work.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top