这将在antrun插件和<contains>
条件的帮助下完成。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<fail message="project.build.directory(${project.build.directory}) contains spaces">
<condition>
<contains string="${project.build.directory}" substring=" "/>
</condition>
</fail>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我已经告诉我的maven-philes避免antrun插件像瘟疫......任何其他的想法? – Jared
@Jared。你可以写20多行,为'maven-enforcer-plugin'创建一个自定义规则。 http://maven.apache.org/enforcer/enforcer-api/writing-a-custom-rule.html。顺便说一句,反对antrun的是什么?在我看来,这是适合正确目的的正确工具。 –
我个人对antrun插件没有异议,但是有些人(包括我公司的人)想要尽可能地避免使用它,因为它经常被用于破解非maven-esque办法。如果没有人提出另一种方式,我会将您的答案标记为已接受的答案。 – Jared