我正在尝试通过配置文件设置条件插件执行。这个想法是有一个压缩/不压缩HTML文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net</groupId>
<artifactId>mavenconditionalexecution</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Maven Conditional Execution</name>
<properties>
<DoCompress>true</DoCompress>
</properties>
<build>
<plugins>
<!-- Clean-up -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>clean</phase>
<configuration>
<target>
<echo message="DoCompress: ${DoCompress}"/>
<delete includeemptydirs="true">
<fileset dir="${basedir}/src/main/webapp/result/" includes="**/*"/>
</delete>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}/src/main/webapp/html</directory>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>With Compression</id>
<activation>
<property>
<name>DoCompress</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.tunyk.mvn.plugins.htmlcompressor</groupId>
<artifactId>htmlcompressor-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>html</goal>
</goals>
</execution>
</executions>
<configuration>
<goalPrefix>htmlcompressor</goalPrefix>
<srcFolder>${basedir}/src/main/webapp/html</srcFolder>
<targetFolder>${basedir}/src/main/webapp/result/html</targetFolder>
<removeIntertagSpaces>true</removeIntertagSpaces>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Without Compression</id>
<activation>
<property>
<name>DoCompress</name>
<value>false</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<echo message="Copying file"/>
<copy todir="${basedir}/src/main/webapp/result/">
<fileset dir="${basedir}/src/main/webapp/html/" >
<include name="angle.html"/>
</fileset>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>com.tunyk.mvn.plugins.htmlcompressor</groupId>
<artifactId>htmlcompressor-maven-plugin</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
无论我为DoCompress
属性指定什么值,都不会执行相应的配置文件。我用echo
检查属性的值。为什么?我做错了什么?
是否允许使用属性值激活pom.xml
中的多个配置文件?
更新
我创建了一个偶发事件:我创建了一起偶发事件:https://jira.codehaus.org/browse/MNG-5235.
如果有人有一个通过属性激活maven配置文件的操作示例,我很感兴趣。此外,有人知道是否可以通过属性在同一次运行中激活多个配置文件吗?文档对此并不清楚。
打开一个问题后,发现这不是一个错误,因为节中的属性只能是系统属性,而不能是pom.xml
本身定义的属性。