|
||||||||
|
This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira |
||||||||
|
||||||||
|
This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira |
||||||||
My own solution to this was as follows:
The simplest way to place our JS project onto the WAR is to overlay a ZIP file onto the WAR file. In this example we will generate a ZIP of the JS projects output and upload it into Maven, will then take advantage of the overlay task to place the project output onto the zip file.
{project.packaging}? arg2=?js? casesensitive=?false?>Firstly rather than define this in every JS project we will take advantage of the skip parameter, this allows us to assemble and attach the ZIP file only on JS projects.
Unfortunately there isn?t a nice way to activate a Maven profile based on packaging type so we have to fall back to using ANT. Again there isn?t a way to run an ANT task across multiple phases so we have to repeat the execution for the clean, compile & site lifecycle phases. This makes sure the property is set no matter what lifecycle phase is called.
<project>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<configuration>
<exportAntProperties>true</exportAntProperties>
</configuration>
<executions>
<execution>
<phase>clean</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<condition property=?is.not.js.project? value=?false? else=?true?>
<equals arg1=?$
<condition>
</target>
</configuration>
</execution>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<condition property=?is.not.js.project? value=?false? else=?true?>
<equals arg1=?${project.packaging}
? arg2=?js? casesensitive=?false?>
{project.packaging}<condition>
</target>
</configuration>
</execution>
<execution>
<phase>site</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<condition property=?is.not.js.project? value=?false? else=?true?>
<equals arg1=?$
? arg2=?js? casesensitive=?false?>
<condition>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Now our skip property is set it is time to make sure a zip file is created as part of the build process, when the _javascript_ tools for Maven plugin is run it places a compilable output under the output directories classes folder.
<project>
{project.build.outputDirectory}<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>make-js-zip</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>true</attach>
<archiveBaseDirectory>$
/classes</archiveBaseDirectory>
{is.not.js.project}<classifier>www</classifier>
<formats>
<format>zip</format>
</formats>
<skip>$
</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Now when we build a zip file of our Jetty running output is converted into a ZIP file and uploaded into the repository. We can overlay this onto the WAR project, this is done by going into the WAR projects POM and entering the following:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<overlays>
<overlay>
<artifactId>project-artifactid</artifactId>
<groupId>project-group-id</groupId>
<classifier>www</classifier>
<type>zip</type>
</overlay>
<overlays>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<artifactId>project-artifactid</artifactId>
<groupId>project-group-id</groupId>
<version>project-version</version>
<classifier>www</classifier>
<type>zip</type>
</dependency>
</dependencies>
...
</project>
You need to define the overlay as a dependency of the WAR project, this should now place the JS, and resources of your project into the WAR.