7

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>

しかし今、s buildfile is wrong. It creates a dist folder on the wrong place. Here's thejquery-ui からのこの 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>

実行mvn clean packageすると、jquery-ui の build.xml の縮小ターゲットで次のエラーが発生します。

[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

正しいパスは、上記の代わりに ${basedir}/src/main/webapp/resources/js/jquery-ui/build/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js である必要があります言及された...

4

2 に答える 2

7

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" />

一方、buildディレクトリの下にディレクトリを作成してもsrcよろしいですか? targetこれはむしろ入るべきではないでしょうか?

于 2012-03-19T13:37:05.537 に答える
0

Ant 呼び出しの代わりに maven プラグインを使用することをお勧めします。docs maven-minify-pluginに基づいて、必要なことを行います。プラグインは Maven Central にあります。さらに、maven-plugin の使用方法については、maven-plugin-documentationを参照してください。

于 2012-03-19T17:52:20.137 に答える