How can I use a default value if an environment variable isn’t set for resource filtering in maven?

I’m using the profile for determining as

<profiles>
  <profile>
    <activation>
      <activeByDefault>true</activeByDefault>
      <property>
        <name>!myproperty</name>
      </property>
    </activation>
    ...
    <properties>
       <myproperty>some value</myproperty>
    </properties>
  </profile>
  ...
</profiles>

Please note

  1. The activeByDefault is set to true with purpose to enable it by default.
  2. The !myproperty means this property is missing or not existed.
  3. If the myproperty is not existed, just use the myproperty defined at the properties instead.

You may see further information at http://maven.apache.org/guides/introduction/introduction-to-profiles.html

I hope this may help to achieve your requirement.

Regards,

Charlee Ch.

Leave a Comment