maven activate by property value and version

347 Views Asked by At

is there a way to activate a profile by property but instead of checking a specific value check for a version range. here is what i am trying to do

<properties>
  <frontend-maven-plugin.version>0.0.16</frontend-maven-plugin.version>
</properties>
...
...
<profile>
  <id>new_version_of_frontend</id>
  <activation>
    <property>
      <name>maven.version</name>
      <value>3.1.0</value>
    </property>
    <properties>
      <frontend-maven-plugin.version>0.0.23</frontend-maven-plugin.version>
    </properties>
  </activation>
</profile>

so the above works (set the frontend plugin version to 0.0.23 when maven version is 3.1.0

what i would like to do is change the condition to 3.1.0 and above something like

<value>[3.1.0,)</value>

but property value check does not support version range. is there any other way to do this? or even check if version is 3.1+

1

There are 1 best solutions below

0
On BEST ANSWER

I believe there is no such functionality with out-of-the-box Maven. Maven is usually really simple when looking into its internals. Profile activation based on property is basically about two strings equality, nothing more, no extra logic here.

I can image a solution that introduces own, simple Maven plugin that does the actual range mechanism and set a property like frontend-maven-plugin.version.within.range to value of true or false. Then your profile activation condition is based on true value of a given property. It might work if you launch your plugin early enough, probably during initialize phase of the lifecycle. I'm not sure however if profiles activation is even earlier or not. You need to verify this.