Domanda

I've got 3 modules:

  • Module1
  • Module2
  • Module3

and 3 profiles:

  • Profile1
  • Profile2
  • Profile3

I'd like to build Module1 if:

  • Profile2 or Profile3 is activated, and
  • Command-line property skipModule1 is not set.

Regardless of whether Module1 is built, Profile2 and Profile3 should build (both) modules Module2 and Module3. Can this be implemented in Maven 3? If so, how?

The problem, as I see it, is that profiles can't activate other profiles and I can't include Module1 as part of Profile2 or Profile3 because there is no way for me to specify that Module1 should be skipped if skipModule1 is not set.

È stato utile?

Soluzione

Although profiles cannot activate other profiles, there is still a workaround you may take.

When building, instead of activating Profile2 and Profile3 explicitly (by -P Profile2,Profile3), activate them by using a variable, so that it looks like mvn compile -DactivateProfile2=true -DactivateProfile3=true.

Then your requirement on Profile1 become straight forward: Profile1 (which includes Module1) is activated by activateProfile2=true, activateProfile3=true, !skipModule1

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top