Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgrade YUI Compressor. Use native Ant task. Fix #28.

Take advantage of Compressor's new CompressorTask
available on its "ant" branch. The HTTP server
is no longer used, which fixes some lingering
JSON encoding problems while keeping builds fast.
  • Loading branch information...
commit d6b3363f311ff3d26649c4f39d23f25874247186 1 parent d37a167
@reid reid authored
View
BIN  componentbuild/lib/yuicompressor/ant-yuicompressor-2.4.5pre2.jar
Binary file not shown
View
BIN  componentbuild/lib/yuicompressor/yuicompressor-2.4.5pre2.jar
Binary file not shown
View
103 componentbuild/shared/macrolib.xml
@@ -70,105 +70,20 @@
</sequential>
</macrodef>
+ <taskdef name="yuicompressor"
+ classname="com.yahoo.platform.yui.compressor.CompressorTask"
+ classpath="${yuicompressor.jar}"/>
+
+ <!-- Maps the legacy yuicompress task into a yuicompressor task. -->
<macrodef name="yuicompress">
<attribute name="src" />
<attribute name="dest" />
<attribute name="args" />
- <attribute name="type" default="js"/>
+ <!-- Unused. Type is detected automatically from the @{src} filename. -->
+ <attribute name="type" default="?"/>
+ <!-- If you had to override this, use the type option in args instead. -->
<sequential>
- <if>
- <or>
- <istrue value="${yuicompressor.online}"/>
- <http url="${yuicompressor.url}" errorsBeginAt="500"/>
- </or>
- <then>
- <property name="yuicompressor.online" value="true"/>
- <property name="yuicompressor.output" value="@{dest}"/>
- <property name="yuicompressor.file" value="@{src}"/>
-
- <!-- FIXME The encoding problems lie here.
-
- I have not yet ruled out the HTTP server as the
- cause of encoding issues. The JSON transformation
- could be causing issues, but I doubt it. Still, I'm
- looking into that now.
-
- The file may be munged by the <echo/> task below
- that writes out the extracted script from JSON
- in the JS snippet and writes it to the -min file.
-
- Your mission, if you choose to accept it, is to
- devise a mechanism that:
- 1. Minifies the file over HTTP
- 2. Displays warnings and errors in the build output.
- 3. Fails the build if minification fails.
- 4. Writes the minified result to a file.
-
- I would suggest testing the HTTP server first to
- make sure it's not the result of encoding problems.
-
- The test you're using should be the yui3 text module.
- Things start to look OK until the wordbreak data script.
- A diff should yeild minor differences (e.g.
- lowercase vars) instead of different Unicode.
- -->
-
- <echo>If this web request fails, try building again with -Dyuicompressor.online=false or install the cURL executable into your PATH.</echo>
- <exec executable="curl" input="@{src}" outputproperty="yuicompressor.result" failonerror="true" searchpath="true">
- <arg value="--silent"/>
- <arg line="-T"/>
- <arg line="${yuicompressor.file}"/>
- <arg line="${yuicompressor.url}?type=@{type}"/>
- </exec>
- <script language="javascript">
- <![CDATA[
- var echo;
- var project = self.getProject();
- var res = project.getProperty("yuicompressor.result");
- res = eval("(" + res + ")");
-
- function w (str, level) {
- var echo = project.createTask("echo");
- echo.setMessage(str);
- echo.perform();
- }
-
- if (!res.result) {
- var fail = project.createTask("fail");
- fail.setMessage("Failed to minify!");
- fail.perform();
- }
-
- function notify (level, errors) {
- for (var i = 0, l = errors.length; i < l; i++) {
- w(errors[i], level);
- }
- }
-
- notify("error", res.errors);
- notify("warning", res.warnings);
-
- project.setProperty("yuicompressor.script", res.result);
-
- ]]>
- </script>
- <!-- XXX: Encoding failure here? -->
- <!-- Setting @encoding on echo didn't work for me, the output was worse. -->
- <echo file="@{dest}" message="${yuicompressor.script}"/>
- <var name="yuicompressor.output" unset="true"/>
- <var name="yuicompressor.script" unset="true"/>
- <var name="yuicompressor.file" unset="true"/>
- <var name="yuicompressor.result" unset="true"/>
- </then>
- <else>
- <echo level="info">Running yuicompressor on @{src} with @{args}</echo>
- <java jar="${yuicompressor.java15.jar}" fork="true" failonerror="true">
- <arg line="@{args} -o" />
- <arg file="@{dest}" />
- <arg file="@{src}" />
- </java>
- </else>
- </if>
+ <yuicompressor input="@{src}" output="@{dest}" options="@{args}"/>
</sequential>
</macrodef>
View
4 componentbuild/shared/properties.xml
@@ -25,8 +25,7 @@
<property name="rhino.jar" location="${builddir}/lib/rhino/js.jar" />
<property name="jslintconsole.js" location="${builddir}/lib/jslint/jslint-console.js" />
<property name="jslintsrc.js" location="${builddir}/lib/jslint/fulljslint.js" />
- <property name="yuicompressor.jar" location="${builddir}/lib/yuicompressor/yuicompressor-2.4.5pre2.jar" />
- <property name="yuicompressor.java15.jar" location="${builddir}/lib/yuicompressor/yuicompressor-2.4.4.jar" />
+ <property name="yuicompressor.jar" location="${builddir}/lib/yuicompressor/ant-yuicompressor-2.4.5pre2.jar" />
<property name="yrb2jsonconsole.js" location="${builddir}/lib/yrb2json/yrb2json-console.js" />
<property name="yrb2jsonsrc.js" location="${builddir}/lib/yrb2json/yrb2json.js" />
@@ -37,7 +36,6 @@
<property name="yuicompressor.js.args" value="--disable-optimizations --preserve-semi --line-break 6000" />
<property name="yuicompressor.css.args" value="--line-break 6000" />
- <property name="yuicompressor.port" value="8091"/>
<!-- Enable/Disable YUI Compressor verbosity. NOTE: Checked in build files should not disable this flag -->
<property name="yuicompressor.js.verbose" value="true" />
View
22 componentbuild/shared/targets.xml
@@ -31,7 +31,6 @@
<tstamp/>
<mkdir dir="${component.builddir}" />
<createdetails />
- <antcall target="-yuicompressor"/>
<antcall target="-lint-server"/>
</target>
@@ -72,27 +71,6 @@
<property name="node.spawn" value="true"/>
</target>
- <target name="-yuicompressor" description="Start YUI Compressor Server" unless="yuicompressor.spawn">
- <if>
- <not>
- <http url="${yuicompressor.url}"/>
- </not>
- <then>
- <echo level="info">Attempting to start YUI Compressor server.</echo>
- <java classname="com.yahoo.platform.yui.compressor.Bootstrap" fork="true" spawn="true" failonerror="false">
- <arg line="--server"/>
- <arg line="${yuicompressor.port}"/>
- <arg line="${yuicompressor.js.args}"/>
- <arg line="${yuicompressor.js.args.internal}"/>
- <classpath>
- <pathelement location="${yuicompressor.jar}"/>
- </classpath>
- </java>
- </then>
- </if>
- <property name="yuicompressor.spawn" value="true"/>
- </target>
-
<target name="clean" description="Clean Local Build Directory" unless="clean.skip">
<delete dir="${component.builddir}" />
</target>
Please sign in to comment.
Something went wrong with that request. Please try again.