這是我目前的文件夾結構:處理的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/resources
js
。 我使用單片機插件來看看這些GitHub的庫:
https://github.com/jquery/jquery
https://github.com/jquery/jquery-ui
這個結帳我需要使用他們的構建機理進行串聯和縮小文件和移動後target/jquery/dist/jquery.min.js
,target/jquery-ui/build/dist/jquery-ui.min.js
,jquery-ui/build/dist/jquery-ui-1.9pre/ui/minified/i18n/jquery-ui-i18n.min.js
到target/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
但是爲什麼?
EDIT2:I pulled a request to jquery-ui to fix this
但現在我需要知道如何移動精縮jQuery的,jQuery的UI和war:excluded
後jQuery的UI的國際化的js文件target/myproject-1.0-SNAPSHOT/resources/js
。
這裏最好的辦法是什麼?