これは私の現在のフォルダ構造です:
.
|-- 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
ご覧のとおり、にはがありjs
ますsrc/main/webapp/resources
。私はこれらのGitHubリポジトリをチェックするためにscmプラグインを使用しています:
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、およびjquery-ui-i18njsファイルをに移動します
target/myproject-1.0-SNAPSHOT/resources/js
- 次に、他のライフサイクルフェーズを実行します
ただし、ステップ2で停止しますmaven-antrun-plugin
。具体的には、外部シェルスクリプトの実行に関する問題は次のとおりです。
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
)間違ったディレクトリを検索します
編集:問題は次のとおりです:minify-js.shが間違った2番目の引数($ 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:これを修正するためにjquery-uiにリクエストをプルしました
しかし、ここで、縮小されたjquery、jquery-ui、およびjquery-ui-i18njsファイルをのtarget/myproject-1.0-SNAPSHOT/resources/js
後に移動する方法を知る必要がありますwar:excluded
。
ここでの最良の方法は何ですか?