在Maven Antrun插件中设置目录

dtr*_*unk 5 maven maven-antrun-plugin

我已经将jquery-ui下载到我的webapp,它有一个build.xml用于压缩和缩小的.现在我想build.xml从我的内部运行pom.xml:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
      <execution>
        <id>compile</id>
        <phase>compile</phase>
        <configuration>
          <target>
            <ant antfile="src/main/webapp/resources/js/jquery-ui/build/build.xml" />
          </target>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
Run Code Online (Sandbox Code Playgroud)

但现在s buildfile is wrong. It creates a dist folder on the wrong place. Here's the来自jquery-ui的thi build.xml` 的行为:https://github.com/jquery/jquery-ui/blob/master/build/build.xml

它在pom.xml所在的同一个地方(我运行的同一个地方mvn clean package)创建了dist文件夹,它应该创建它src/main/webapp/resources/js/jquery-ui/build

是否可以build.xml从指定目录(工作目录)运行?无法访问Ant任务的文档:http://ant.apache.org/manual/CoreTasks/ant.html

编辑:pom.xml

<?xml version="1.0" encoding="utf-8"?>
<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>com.example.myproject</groupId>
  <artifactId>myproject</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>myproject</name>

  <dependencies>
    <!-- ... -->
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <!-- ... -->
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <warName>myproject</warName>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>install</id>
            <phase>install</phase>
            <goals>
              <goal>sources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>compile</phase>
            <configuration>
              <executable>make</executable>
              <workingDirectory>src/main/webapp/resources/js/jquery</workingDirectory>
            </configuration>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>compile</phase>
            <configuration>
              <target>
                <ant antfile="build.xml" dir="src/main/webapp/resources/js/jquery-ui/build" />
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
Run Code Online (Sandbox Code Playgroud)

在运行时,mvn clean package我在jquery-ui的build.xml的minify目标中遇到以下错误:

[apply] build/minify-js.sh: Line 3: /home/danny/myproject/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js: File or directory not found
Run Code Online (Sandbox Code Playgroud)

正确的路径应该是$ {basedir} /src/main/webapp/resources/js/jquery-ui/build/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js而不是上述提到...

nwi*_*ler 5

根据http://ant.apache.org/manual/Tasks/ant.html,您可以使用以下dir属性:

<mkdir dir="${project.build.directory}/jquery-ui" />
<ant antfile="src/main/webapp/resources/js/jquery-ui/build/build.xml" dir="${project.build.directory}/jquery-ui" />
Run Code Online (Sandbox Code Playgroud)

另一方面,您确定要在build目录下创建src目录吗?这不应该成为事实target吗?