我收到以下错误。是因为install_path
没有设置吗?如果是这样,这是否意味着在使用配置文件时,不会执行默认插件(设置install_path
的插件)?
执行:
mvn clean install site -Pfull
错误:
未能执行目标 org.apache.maven.plugins:maven-clean-plugin:2.5:clean (清理部署文件夹)在项目 bo-full 上:缺少 文件集:空(包括:[],排除:[])
家长:
<project>
<plugins>
<plugin>
<!-- Workaround maven not being able to set a property conditionally based on environment variable -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<exportAntProperties>true</exportAntProperties>
<target>
<property environment="env"/>
<condition property="install.path" value="${env.SERVER_HOME}" else="C:MY_SERVER">
<isset property="env.SERVER_HOME" />
</condition>
<echo message="${install.path}"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
...
儿童:
<project>
<profiles>
<profile>
<id>full</id>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean-deploy-folder</id>
<phase>pre-site</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>${install.path}</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
...
1)即使使用配置文件,也应该执行默认插件。请通过以下构建日志验证是否发生这种情况 - 每个插件执行都由 maven 记录,即使插件本身没有记录任何内容。
2) 您应该将清理执行保留在与创建属性的执行相同的 Maven 项目/模块中。一个原因是您的子模块可以单独构建(它将使用本地/远程存储库中的父 pom.xml(如果可用)。无论出于何种原因,属性也可能没有在反应堆构建中正确传播。
3)如果问题确实是属性传播并且antrun插件有问题,你可以用Maven配置文件替换antrun执行。它应该是这样的:
<properties>
<!-- default value goes here: -->
<install.path>C:MY_SERVER</install.path>
</properties>
<profiles>
<profile>
<id>env</id>
<activation>
<property>
<!-- activate this profile when property is specified: -->
<name>env.SERVER_HOME</name>
</property>
</activation>
<properties>
<!-- override default property value: -->
<install.path>${env.SERVER_HOME}</install.path>
</properties>
</profile>
</profiles>