2012-04-13 64 views
2

我想只在maven-war-plugin中排除某些文件,当属性“skipCompress”设置为true时,我想我可以做这样的事情,但它不适用于我。顺便说一句,我不能使用配置文件来实现这一点,即使我想使用skipCompress在开发和部署配置文件中打开和关闭压缩。maven pom.xml中的条件配置

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

感谢,

大卫

+0

你自己给出了答案。使用这种配置文件。 – khmarbaise 2012-04-15 08:50:52

回答

2

没有真正理解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> 
+0

''settings.xml的元素没​​有''元素:http://maven.apache.org/ref/2.2.1/maven-settings/settings.html – maksimov 2014-02-13 22:50:16

+0

它在'pom.xml ':https://maven.apache.org/ref/3.1.0/maven-model/maven.html – ralfstx 2014-02-15 20:56:32

+0

谢谢@ralfstx,我很着迷于通过全局配置工作。 – maksimov 2014-02-16 16:31:55