Author: kevj
Date: Thu Jan 1 08:02:22 2009
New Revision: 730558
URL: http://svn.apache.org/viewvc?rev=730558&view=rev
Log:
-first commit of YUI compressor antlib
Added:
ant/sandbox/antlibs/compress/trunk/NOTICE
ant/sandbox/antlibs/compress/trunk/README
ant/sandbox/antlibs/compress/trunk/build.xml
ant/sandbox/antlibs/compress/trunk/contributors.xml
ant/sandbox/antlibs/compress/trunk/lib/
ant/sandbox/antlibs/compress/trunk/lib/yuicompressor-2.3.6.jar (with
props)
ant/sandbox/antlibs/compress/trunk/libraries.properties
ant/sandbox/antlibs/compress/trunk/src/
ant/sandbox/antlibs/compress/trunk/src/etc/
ant/sandbox/antlibs/compress/trunk/src/etc/testcases/
ant/sandbox/antlibs/compress/trunk/src/etc/testcases/compress.xml
ant/sandbox/antlibs/compress/trunk/src/main/
ant/sandbox/antlibs/compress/trunk/src/main/org/
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/YUICompressorTask.java
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/antlib.xml
Added: ant/sandbox/antlibs/compress/trunk/NOTICE
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/NOTICE?rev=730558&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/NOTICE (added)
+++ ant/sandbox/antlibs/compress/trunk/NOTICE Thu Jan 1 08:02:22 2009
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0 ==
+ =========================================================================
+
+ Apache JavaScript Compressor Ant Library
+ Copyright 2008 The Apache Software Foundation
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
Added: ant/sandbox/antlibs/compress/trunk/README
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/README?rev=730558&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/README (added)
+++ ant/sandbox/antlibs/compress/trunk/README Thu Jan 1 08:02:22 2009
@@ -0,0 +1,4 @@
+This library provides Ant task(s) that compress input JavaScript and CSS files.
+
+Currently the Yahoo UI Compressor is supported and is required on Ant's
classpath.
+
Added: ant/sandbox/antlibs/compress/trunk/build.xml
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/build.xml?rev=730558&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/build.xml (added)
+++ ant/sandbox/antlibs/compress/trunk/build.xml Thu Jan 1 08:02:22 2009
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="compile" name="compressor">
+
+ <!-- easy way to override properties -->
+ <property file="build.properties"/>
+
+ <import file="common/build.xml"/>
+
+ <target name="clean" depends="common.clean">
+ <delete dir="tmpdir"/>
+ </target>
+
+ <!-- requires classpath setup as depends on YUICompressor.jar -->
+ <target name="compile" depends="setup">
+ <javac
+ srcdir="src/main"
+ destdir="${build.classes}"
+ debug="${javac.debug}"
+ source="${javac.-source}"
+ target="${javac.-target}"
+ >
+ <classpath>
+ <fileset dir="${basedir}/lib"/>
+ </classpath>
+ </javac>
+ </target>
+</project>
\ No newline at end of file
Added: ant/sandbox/antlibs/compress/trunk/contributors.xml
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/contributors.xml?rev=730558&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/contributors.xml (added)
+++ ant/sandbox/antlibs/compress/trunk/contributors.xml Thu Jan 1 08:02:22 2009
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE contributors
+[
+<!ELEMENT name (first?, middle?, last)>
+<!ELEMENT contributors (introduction, name+)>
+<!ELEMENT first (#PCDATA)>
+<!ELEMENT introduction (#PCDATA)>
+<!ELEMENT middle (#PCDATA)>
+<!ELEMENT last (#PCDATA)>
+]
+>
+
+<contributors>
+ <introduction>
+ These are some of the many people who have helped with this Ant Library.
+ </introduction>
+ <name>
+ <first>Kevin</first>
+ <last>Jackson</last>
+ </name>
+</contributors>
Added: ant/sandbox/antlibs/compress/trunk/lib/yuicompressor-2.3.6.jar
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/lib/yuicompressor-2.3.6.jar?rev=730558&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ant/sandbox/antlibs/compress/trunk/lib/yuicompressor-2.3.6.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ant/sandbox/antlibs/compress/trunk/libraries.properties
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/libraries.properties?rev=730558&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/libraries.properties (added)
+++ ant/sandbox/antlibs/compress/trunk/libraries.properties Thu Jan 1 08:02:22
2009
@@ -0,0 +1,15 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+artifact.version=1.0-beta-SNAPSHOT
\ No newline at end of file
Added: ant/sandbox/antlibs/compress/trunk/src/etc/testcases/compress.xml
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/etc/testcases/compress.xml?rev=730558&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/etc/testcases/compress.xml (added)
+++ ant/sandbox/antlibs/compress/trunk/src/etc/testcases/compress.xml Thu Jan
1 08:02:22 2009
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project name="compress-test" basedir="../../../"
+ default="all" xmlns:compress="antlib:org.apache.ant.js.compressor">
+
+ <property name="output" value="test.js"/>
+ <property name="outputPath" value="."/>
+
+ <target name="all">
+ <compress:yui.compressor verbose="true" output="${output}"
mergefiles="true" type="js">
+ <fileset dir="testscripts">
+ <include name="*.js"/>
+ </fileset>
+ </compress:yui.compressor>
+
+ <compress:yui.compressor verbose="true" outputPath="${outputPath}"
type="js">
+ <fileset dir="testscripts">
+ <include name="*.js"/>
+ </fileset>
+ </compress:yui.compressor>
+ </target>
+
+ <target name="cleanup">
+ <delete file="${output}" />
+ </target>
+</project>
Added:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/YUICompressorTask.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/YUICompressorTask.java?rev=730558&view=auto
==============================================================================
---
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/YUICompressorTask.java
(added)
+++
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/YUICompressorTask.java
Thu Jan 1 08:02:22 2009
@@ -0,0 +1,190 @@
+package org.apache.ant.js.compressor;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.io.File;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.FileResource;
+
+import com.yahoo.platform.yui.compressor.YUICompressor;
+
+
+public class YUICompressorTask extends Task {
+
+ private boolean verbose;
+ private boolean nomunge;
+ private String type;
+ private String lineBreak;
+ private boolean preserveSemi;
+ private boolean disableOptimization;
+ private String charset;
+ private String output;
+ private String outputPath;
+ private boolean mergeFiles;
+ private List inputResources = new ArrayList();
+
+ public void execute() {
+ if(mergeFiles) {
+ Commandline cmd = buildArgs();
+ YUICompressor.main(cmd.getArguments());
+ } else {
+ for(Iterator i = inputResources.iterator();
i.hasNext();) {
+ FileSet fs = (FileSet)i.next();
+ for(Iterator j = fs.iterator(); j.hasNext();) {
+ Commandline cmd = buildArgs();
+ FileResource f = (FileResource)j.next();
+ if(verbose) {
+ log("Minifying:
"+f.getFile().getAbsolutePath());
+ }
+ cmd.createArgument().setValue("-o");
+ if(null != outputPath &&
outputPath.trim() != "") {
+
cmd.createArgument().setValue(outputPath + File.separator +
f.getFile().getAbsolutePath());
+ } else {
+
cmd.createArgument().setValue(f.getFile().getAbsolutePath());
+ }
+
cmd.createArgument().setValue(f.getFile().getAbsolutePath());
+ YUICompressor.main(cmd.getArguments());
+ }
+
+ }
+ }
+ }
+
+ protected Commandline buildArgs() {
+ Commandline cmd = new Commandline();
+ if(verbose) {
+ cmd.createArgument().setValue("-v");
+ }
+ if(nomunge) {
+ cmd.createArgument().setValue("--nomunge");
+ }
+ if(preserveSemi) {
+ cmd.createArgument().setValue("--preserve-semi");
+ }
+ if(disableOptimization) {
+
cmd.createArgument().setValue("--disable-optimizations");
+ }
+ if(null != lineBreak && lineBreak.trim() != "") {
+ cmd.createArgument().setValue("--line-break");
+ cmd.createArgument().setValue(lineBreak);
+ }
+ if(null != type && type.trim() != "") {
+ cmd.createArgument().setValue("--type");
+ cmd.createArgument().setValue(type);
+ }
+ if(null != charset && charset.trim() != "") {
+ cmd.createArgument().setValue("--charset");
+ cmd.createArgument().setValue(charset);
+ }
+ if(null != output && output.trim() != "" && mergeFiles) {
+ cmd.createArgument().setValue("-o");
+ cmd.createArgument().setValue(output);
+ }
+
+ if(mergeFiles) {
+ for(Iterator i = inputResources.iterator();
i.hasNext();) {
+ FileSet fs = (FileSet)i.next();
+ for(Iterator j = fs.iterator(); j.hasNext();) {
+ FileResource f = (FileResource)j.next();
+
cmd.createArgument().setValue(f.getFile().getAbsolutePath());
+ }
+
+ }
+ }
+ log("args: "+cmd.describeCommand());
+ return cmd;
+ }
+
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ public boolean isNomunge() {
+ return nomunge;
+ }
+
+ public void setNomunge(boolean nomunge) {
+ this.nomunge = nomunge;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getLineBreak() {
+ return lineBreak;
+ }
+
+ public void setLineBreak(String lineBreak) {
+ this.lineBreak = lineBreak;
+ }
+
+ public boolean isPreserveSemi() {
+ return preserveSemi;
+ }
+
+ public void setPreserveSemi(boolean preserveSemi) {
+ this.preserveSemi = preserveSemi;
+ }
+
+ public boolean isDisableOptimization() {
+ return disableOptimization;
+ }
+
+ public void setDisableOptimization(boolean disableOptimization) {
+ this.disableOptimization = disableOptimization;
+ }
+
+ public String getCharset() {
+ return charset;
+ }
+
+ public void setCharset(String charset) {
+ this.charset = charset;
+ }
+
+ public String getOutput() {
+ return output;
+ }
+
+ public void setOutput(String output) {
+ this.output = output;
+ }
+
+ public String getOutputPath() {
+ return outputPath;
+ }
+
+ public void setOutputPath(String outputPath) {
+ this.outputPath = outputPath;
+ }
+
+ public void addFileSet(FileSet fs) {
+ add(fs);
+ }
+
+ public void add(ResourceCollection res) {
+ inputResources.add(res);
+ }
+
+ public boolean isMergeFiles() {
+ return mergeFiles;
+ }
+
+ public void setMergeFiles(boolean m) {
+ mergeFiles = m;
+ }
+}
Added:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/antlib.xml
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/antlib.xml?rev=730558&view=auto
==============================================================================
---
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/antlib.xml
(added)
+++
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/js/compressor/antlib.xml
Thu Jan 1 08:02:22 2009
@@ -0,0 +1,6 @@
+<antlib>
+ <taskdef
+ name="yui.compressor"
+ classname="org.apache.ant.js.compressor.YUICompressorTask"
+ />
+</antlib>
\ No newline at end of file