Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set a property value according to profile

Tags:

maven

I'm new to maven and i got this issue when sometimes when i run maven i want to have a property with 1 value and sometimes the other. I tried to do the following but still something is missing:

 <profiles>
<profile>
    <id>production</id>
    <activation>
        <property>
            <name>com.sencha.cmd.dir</name>
            <value>
                ${env.SENCHA_PATH}\senchaCmd-${com.sencha.cmd.version}\Sencha\Cmd\${com.sencha.cmd.version}
            </value>
        </property>
    </activation>
</profile>
</profiles>

<properties>
 <com.sencha.cmd.dir> ${env.SENCHA_PATH}\senchaCmd- ${com.sencha.cmd.version}\Sencha\Cmd\${com.sencha.cmd.version}</com.sencha.cmd.dir>

my question is how to replace the value of the property com.sencha.cmd.dir according to the availability of the profile?

Hope this is clear enough

like image 564
Nir Avatar asked Sep 05 '25 16:09

Nir


1 Answers

It's really simple

<profiles>
 <profile>
   <id>profile 1</id>
   <activation>
     ...
   </activation>
   <properties>
     <my.property> xxx </my.property>
   </properties>
 </profile>
 <profile>
   <id>profile 2</id>
   <activation>
     ...
   </activation>
   <properties>
     <my.property> yyy </my.property>
   </properties>
 </profile>
</profiles>

and then you can use your my.properties outside, even in an other one properties

<properties>
 <my.next.property> abc ${my.property} def </my.next.property>
</properties>
like image 66
Jérome Pieret Avatar answered Sep 07 '25 17:09

Jérome Pieret