Hello, I found this ticket : https://issues.apache.org/jira/browse/MNG-5909 to match one of my current problems. I have 3 profiles (A, B and C) each activated on file existence criteria. I need to change it so that : - if fileA is missing, none of these profiles must be active - if file A is present, then A must be active + B must be active if fileBC is missing - if file A is present, then A must be active + C must be active if fileBC is present, in which case B must NOT be active This can not be expressed in the current version of maven. Accepting multiple <file> elements in the POM (changing the model), as suggested in the ticket, seemed complex to do and I was worried that I could break compatibility.Instead, I implemented a simple solution that fits my needs : my patched maven now understands basic logic in file-based profile activation.In my POM now I have :<activation> <file> <exists>and(fileA,!fileBC)</exists> </file></activation>(this is for profile B, of course C has the same without the negation). My implementation accepts boolean operators AND (expressed as and() or all() ), OR (expressed as or() or any() ) and NOT (expressed with an exclamation mark, applicable only on the inner value, not left of the operator). Nested conditions are not supported.For more examples of supported expressions, please see the added unit test.
If you think this can be useful to others, please consider merging the pull request here : MNG-5909 : Add combined expression evaluator to file activation property by lbndev · Pull Request #92 · apache/maven | | | | | | | | | | | MNG-5909 : Add combined expression evaluator to file act...Suggested solution for MNG-5909 : the file activation element will understand basic boolean expressions such as and(file1,file2) or(file3,!file4) etc... Please see ... | | | | Afficher sur github.com | Aperçu par Yahoo | | | | | If you think this simple "boolean conditions" feature could be usefully added to other activation criteria (properties and OS for example), please say so and I will happily wire it there too. Comments and feedback are welcome, Loïc
