maven-3 – maven pom.xml中的条件配置

当属性“skipCompress”设置为true时,我只想使用maven-war-plugin排除某些文件.我认为以下规范可能有效,但事实并非如此.顺便说一句,我无法使用配置文件来实现这一目标.我想使用skipCompress在开发和部署配置文件中打开和关闭压缩.

<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>

谢谢,

大卫

最佳答案 在没有真正理解maven配置文件的情况下,我使用如下模式解决了类似的问题.也许它对你的情况也有帮助.

<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>
点赞