开发者

How can I test for spaces in the path and give an appropriate error?

开发者 https://www.devze.com 2023-03-25 03:44 出处:网络
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 cavea

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号