1

I have a maven profile for skipping tests and license checks which looks the following way:

<profiles>
    <profile>
        <id>myProfile</id>
        <properties>
            <license.skip>true</license.skip>
            <skipTests>true</skipTests>
        </properties>
    </profile>
</profiles>

The profile works like a charm and does what I want (skipping tests / license checks) when I launch it via:

mvn clean verify -PmyProfile

Now I want to add yet another system property to the profile which I can enable explicitly:

mvn clean verify -Dskip-validate-sources 

However, when I try to add it to my profile:

<skip-validate-sources>true</skip-validate-sources>

or

<skip-validate-sources></skip-validate-sources>

It does not seem to work. Basically, this property enables another profile which is defined the following way:

        <profile>
            <id>validate-sources</id>
            <activation>
                <property>
                    <name>!skip-validate-sources</name>
                </property>
            </activation>
....

Any ideas how is it possible to define a system property which does not have value in a maven profile ?

Ilya Buziuk
  • 1,839
  • 5
  • 27
  • 43
  • Why are you trying to define a property without a value? Can you explain your use case? What should happen when running `mvn clean verify -Dskip-validate-sources`? Or do you mean that, by default, `skip-validate-sources` should be `false`, and it should only be `true` when the profile `myProfile` is activated? – Tunaki Oct 11 '16 at 16:11
  • @Tunaki hi, I'm not trying to define it - it is already defined, All I want to do is to run my profile with this property enabled i.e. use my profile instead of "mvn clean verify -Dskip-validate-sources -DskipTests=true -Dlicense.skip=true" (the property skips resource validation) – Ilya Buziuk Oct 11 '16 at 16:19
  • Well adding `true` in the properties of the `myProfile` profile will certainly define it to `true` when the profile is activated with `mvn -PmyProfile`. The problem is elsewhere, i.e. where that property is used. Can you post the config using this property? It is not a standard one of the Maven plugins. – Tunaki Oct 11 '16 at 16:22
  • @Tunaki this property should actually enable another profile which is enabled when `!skip-validate-sources` - http://pastebin.com/5Yt6kyCx – Ilya Buziuk Oct 11 '16 at 16:24
  • 1
    You should have said that before. Please edit your post with all the info. You cannot activate a profile when another one is activated (some sort of chaining activation), see also http://stackoverflow.com/questions/943411/can-i-make-one-maven-profile-activate-another – Tunaki Oct 11 '16 at 16:27
  • @Tunaki, Thank you - I have updated the question. However, still trying to understand how to enable `validate-sources` profile from `myProfile` – Ilya Buziuk Oct 11 '16 at 16:33
  • 1
    Like I commented before, you can't do that. See http://stackoverflow.com/questions/943411/can-i-make-one-maven-profile-activate-another and http://stackoverflow.com/questions/2246033/why-cant-i-activate-a-maven2-profile-from-another-profile?noredirect=1&lq=1 You need to use a system property that activates them both. – Tunaki Oct 11 '16 at 16:35

0 Answers0