This is my current folder structure:
.
|-- 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
As you can see there's js
in src/main/webapp/resources
.
I'm using the scm plugin to check out these GitHub repositories:
https://github.com/jquery/jquery
https://github.com/jquery/jquery-ui
After this checkout I need to use their build machanism for concatenating and minifying and move 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
to target/myproject-1.0-SNAPSHOT/resources/js
.
Here's the necessary snippet of my 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>
I just need the following steps:
exec-maven-plugin
to use jquery's concatenating+minifying mechanism (Makefile)maven-antrun-plugin
to use jquery-ui's concatenating+minifying mechanism (Ant build.xml)target/myproject-1.0-SNAPSHOT/resources/js
But it stops on Step 2: maven-antrun-plugin
.
To be more specific, the problem here on running the external shell script:
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
...
The script looks on the wrong directory (/home/danny/myproject/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js
instead of /home/danny/myproject/target/jquery-ui/build/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js
)
EDIT: Problem is: minify-js.sh gets a wrong second argument ($2).
Adding this to modify-js.sh: echo "test: $1 -> $2"
results in: 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
But why?
EDIT2: I pulled a request to jquery-ui to fix this
But now I need to know how to move the minified jquery, jquery-ui and jquery-ui-i18n js files to target/myproject-1.0-SNAPSHOT/resources/js
after war:excluded
.
What's the best way here?
I'd add another execution to your 'maven-antrun-plugin' that runs an ant 'move' command and moves everything you need.
Frankly you'll have to experiment on which phase you'll want to bind this to. I'm guessing that war:excluded is being run during the 'package' phase. If that's the case then, since maven doesn't have a step between package and integration tests, you can: