Created
June 8, 2011 17:47
-
-
Save imranansari/1014911 to your computer and use it in GitHub Desktop.
Maven ANT JS Build Tasks with YUI Compressor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- JS tasks --> | |
<plugin> | |
<dependencies> | |
<dependency> | |
<groupId>commons-net</groupId> | |
<artifactId>commons-net</artifactId> | |
<version>1.4.1</version> | |
</dependency> | |
<dependency> | |
<groupId>ant</groupId> | |
<artifactId>ant-commons-net</artifactId> | |
<version>1.6.5</version> | |
</dependency> | |
<dependency> | |
<groupId>ant</groupId> | |
<artifactId>ant-nodeps</artifactId> | |
<version>1.6.5</version> | |
</dependency> | |
<dependency> | |
<groupId>com.yahoo.yui</groupId> | |
<artifactId>yuicompressor</artifactId> | |
<version>2.4.6</version> | |
</dependency> | |
</dependencies> | |
<artifactId>maven-antrun-plugin</artifactId> | |
<version>1.1</version> | |
<executions> | |
<execution> | |
<phase>generate-sources</phase> | |
<configuration> | |
<tasks> | |
<property name="compile_classpath" refid="maven.compile.classpath" /> | |
<property name="runtime_classpath" refid="maven.runtime.classpath" /> | |
<property name="test_classpath" refid="maven.test.classpath" /> | |
<property name="plugin_classpath" refid="maven.plugin.classpath" /> | |
<echo message="Versioning JS" /> | |
<propertyfile file="${basedir}/release.properties" | |
comment="Release Properties"> | |
<entry key="release.ver" type="int" default="0001" | |
operation="+" pattern="0000" /> | |
<entry key="release.date" type="date" value="now" | |
pattern="MM/dd/yyyy hh:mm" /> | |
</propertyfile> | |
<property file="${basedir}/release.properties" /> | |
<copy todir="${basedir}/src/main/webapp/js/versioned_js"> | |
<fileset dir="${basedir}/src/main/webapp/js" includes="*.js" /> | |
<globmapper from="*.js" to="*_${release.ver}.js" /> | |
</copy> | |
<echo message="Compressing JS" /> | |
<echo message="plugin cp : " /> | |
<apply executable="java" parallel="false"> | |
<fileset dir="${basedir}/src/main/webapp/js/versioned_js" | |
includes="*.js" /> | |
<arg line="-jar" /> | |
<arg | |
path="C:/Users/IXANSAR.JPDOMAIN/.m2/repository/com/yahoo/yui/yuicompressor/2.4.6/yuicompressor-2.4.6.jar" /> | |
<srcfile /> | |
<arg line="-o" /> | |
<mapper type="glob" from="*.js" | |
to="${basedir}/src/main/webapp/js/versioned_js/compressed/*.min.js" /> | |
<targetfile /> | |
</apply> | |
</tasks> | |
</configuration> | |
<goals> | |
<goal>run</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<!-- End JS Tasks --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment