I am trying to write a开发者_运维技巧n integration test POM for our project. We've got the project downloading and installing/unzipping appropriately (using the maven-dependency-plugin), but one caveat of our project is that it can't yet run in paths that have spaces in them. I'm looking for a very simple way to evaluate ${project.build.directory} and throw a human readable error if it contains spaces. I'd like this to happen BEFORE downloading dependencies, since this takes quite a bit of time.
This will do it with the help of antrun plugin and <contains>
condition.
<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>
精彩评论