Maven pom.xml中的条件配置

Dav*_*hao 5 pom.xml maven-3 maven-war-plugin

当属性“ 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>
Run Code Online (Sandbox Code Playgroud)

谢谢,

大卫

ral*_*stx 4

在没有真正理解 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>
Run Code Online (Sandbox Code Playgroud)