1

這是我目前的文件夾結構:處理的jQuery + jQuery UI的資源與Maven

. 
|-- pom.xml 
`-- src 
    `-- main 
     |-- java 
     | `-- ... 
     |-- resources 
     | `-- messages 
     |  `-- messages.properties 
     |  `-- ... 
     | `-- properties 
     |  `-- hibernate.properties 
     |  `-- jawr.properties 
     |  `-- ... 
     | `-- log4j.xml 
     | `-- tiles.xml 
     `-- webapp 
      |-- resources 
      | `-- css 
      |  `-- ... 
      | `-- images 
      |  `-- ... 
      | `-- js 
      |  `-- main.js 
      |-- WEB-INF 
      | `-- context 
      |  `-- application.xml 
      |  `-- hibernate.xml 
      |  `-- security.xml 
      |  `-- servlet.xml 
      | `-- views 
      |  `-- ... 
      | `-- redirect.jsp 
      | `-- web.xml 

正如你可以看到有在src/main/webapp/resourcesjs。 我使用單片機插件來看看這些GitHub的庫:

https://github.com/jquery/jquery

https://github.com/jquery/jquery-ui

這個結帳我需要使用他們的構建機理進行串聯和縮小文件和移動後target/jquery/dist/jquery.min.jstarget/jquery-ui/build/dist/jquery-ui.min.jsjquery-ui/build/dist/jquery-ui-1.9pre/ui/minified/i18n/jquery-ui-i18n.min.jstarget/myproject-1.0-SNAPSHOT/resources/js

這裏是我的pom.xml的必要片段:

<plugins> 

    <plugin> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <configuration> 
     <source>${java.version}</source> 
     <target>${java.version}</target> 
     <showWarnings>true</showWarnings> 
    </configuration> 
    </plugin> 

    <plugin> 
    <artifactId>maven-war-plugin</artifactId> 
    </plugin> 

    <plugin> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <executions> 
     <execution> 
     <phase>install</phase> 
     <goals> 
      <goal>sources</goal> 
     </goals> 
     </execution> 
    </executions> 
    </plugin> 

    <plugin> 
    <artifactId>maven-scm-plugin</artifactId> 
    <executions> 
     <execution> 
     <id>checkout-jquery</id> 
     <phase>compile</phase> 
     <goals> 
      <goal>checkout</goal> 
     </goals> 
     <configuration> 
      <connectionUrl>scm:git:git://github.com/jquery/jquery.git</connectionUrl> 
      <checkoutDirectory>${project.build.directory}/jquery</checkoutDirectory> 
     </configuration> 
     </execution> 
     <execution> 
     <id>checkout-jquery-ui</id> 
     <phase>compile</phase> 
     <goals> 
      <goal>checkout</goal> 
     </goals> 
     <configuration> 
      <connectionUrl>scm:git:git://github.com/jquery/jquery-ui.git</connectionUrl> 
      <checkoutDirectory>${project.build.directory}/jquery-ui</checkoutDirectory> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

    <plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
    <executions> 
     <execution> 
     <phase>compile</phase> 
     <goals> 
      <goal>exec</goal> 
     </goals> 
     <configuration> 
      <executable>make</executable> 
      <workingDirectory>${project.build.directory}/jquery</workingDirectory> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

    <plugin> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <executions> 
     <execution> 
     <phase>compile</phase> 
     <goals> 
      <goal>run</goal> 
     </goals> 
     <configuration> 
      <target> 
      <ant antfile="build.xml" dir="${project.build.directory}/jquery-ui/build" /> 
      </target> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

</plugins> 

我只需要進行如下操作:

  • 使用exec-maven-plugin使用jQuery的串接+縮小文件機制(Makefile文件)
  • 使用maven-antrun-plugin使用jquery-ui的連接+縮小機制(Ant build.xml)
  • 移動縮小的jquery,jquery-ui和jqu ERY-UI-國際化的js文件target/myproject-1.0-SNAPSHOT/resources/js
  • 然後做其他的生命週期階段

,但是它停止在第2步:maven-antrun-plugin。 具體而言,上運行的外部shell腳本問題here

minify: 
    [echo] Building minified 
    [mkdir] Created dir: /home/danny/myproject/target/jquery-ui/build/dist/jquery-ui-1.9pre/ui/minified 
    [mkdir] Created dir: /home/danny/myproject/target/jquery-ui/build/dist/jquery-ui-1.9pre/ui/minified/i18n 
    [mkdir] Created dir: /home/danny/myproject/target/jquery-ui/build/dist/jquery-ui-1.9pre/themes/base/minified 
    [apply] build/minify-js.sh: Line 3: /home/danny/myproject/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js: File or folder not found 
    [apply] Result: 1 
    ... 

腳本看起來錯誤的目錄(的/home/danny/myproject/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js代替/home/danny/myproject/target/jquery-ui/build/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js

編輯:問題是:縮小-JS .sh得到錯誤的第二個參數($ 2)。 將此添加到modify-js.sh:echo "test: $1 -> $2"結果在:test: /home/danny/myproject/target/jquery-ui/build/dist/jquery-ui-1.9pre/ui/jquery-ui.js -> /home/danny/myproject/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js但是爲什麼?

EDIT2I pulled a request to jquery-ui to fix this

但現在我需要知道如何移動精縮jQuery的,jQuery的UI和war:excluded後jQuery的UI的國際化的js文件target/myproject-1.0-SNAPSHOT/resources/js

這裏最好的辦法是什麼?

回答

1

我會添加另一個執行到你的'maven-antrun-plugin',它運行一個ant'move'命令並移動你需要的所有東西。

坦率地說,你將不得不試驗你想要將它綁定到哪個階段。我猜測,戰爭:被排除在「包裹」階段。如果是這樣的話,那麼,因爲行家沒有包和集成測試之間的臺階,您可以:

  1. 嘗試綁定它「包」,看看它是否戰後運行:排除
  2. 綁定它進行預集成測試。它與集成測試沒有任何關係,但至少你會確信它在戰後運行:排除在外。