Conditional configuration in maven pom.xml

David Zhao picture David Zhao · Apr 14, 2012 · Viewed 8.4k times · Source

I'd like to ONLY exclude certain files using the maven-war-plugin when the property "skipCompress" is set to true. I thought the following specification might work, but it doesn't. BTW, I can't use a profile to achieve this. I want to use skipCompress to turn on and off the compression in both development and deployment profiles.

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
    <if>
        <not>
        <equals arg1="${skipCompress}" arg2 = "true"/>
        </not>
        <then>
        <warSourceExcludes>**/external/dojo/**/*.js</warSourceExcludes>
        </then>
    </if>
    </configuration>
</plugin>

Thanks,

David

Answer

ralfstx picture ralfstx · Jun 16, 2012

Without really understanding maven profiles, I solved a similar problem using a pattern like the following. Maybe it is helpful in your case too.

<profiles>
  <profile>
    <id>skipCompress</id>
    <activation>
      <property>
        <name>skipCompress</name>
        <value>true</value>
      </property>
    </activation>
    <build>
      <plugins>
        <plugin>
          <artifactId>maven-war-plugin</artifactId>
          <configuration>
            <warSourceExcludes>**/external/dojo/**/*.js</warSourceExcludes>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>