tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject tapestry-5 git commit: TAP5-2304: Define a IoC symbol for setting the Google Closure Compiler compilation level
Date Mon, 01 Jun 2015 23:59:12 GMT
Repository: tapestry-5
Updated Branches:
  refs/heads/master 20d7d83d9 -> 87832dd4b


TAP5-2304: Define a IoC symbol for setting the Google Closure Compiler compilation level


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/87832dd4
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/87832dd4
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/87832dd4

Branch: refs/heads/master
Commit: 87832dd4bafcf97442306e92d12d36a101f5aec7
Parents: 20d7d83
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Mon Jun 1 16:59:05 2015 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Mon Jun 1 16:59:05 2015 -0700

----------------------------------------------------------------------
 .../internal/webresources/GoogleClosureMinimizer.java    | 11 ++++++++++-
 .../tapestry5/webresources/WebResourcesSymbols.java      |  9 +++++++++
 .../webresources/modules/WebResourcesModule.java         |  2 ++
 3 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/87832dd4/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizer.java
----------------------------------------------------------------------
diff --git a/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizer.java
b/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizer.java
index ee6669c..e3102ac 100644
--- a/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizer.java
+++ b/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizer.java
@@ -17,11 +17,13 @@ import com.google.javascript.jscomp.Compiler;
 import org.apache.commons.io.IOUtils;
 import org.apache.tapestry5.TapestryConstants;
 import org.apache.tapestry5.ioc.OperationTracker;
+import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.services.Request;
 import org.apache.tapestry5.services.assets.AssetChecksumGenerator;
 import org.apache.tapestry5.services.assets.StreamableResource;
+import org.apache.tapestry5.webresources.WebResourcesSymbols;
 import org.slf4j.Logger;
 
 import java.io.IOException;
@@ -42,16 +44,20 @@ public class GoogleClosureMinimizer extends AbstractMinimizer
     private final List<SourceFile> EXTERNS = Collections.emptyList();
 
     private final Request request;
+    private final CompilationLevel compilationLevel;
 
     static
     {
         Compiler.setLoggingLevel(Level.SEVERE);
     }
 
-    public GoogleClosureMinimizer(Logger logger, OperationTracker tracker, AssetChecksumGenerator
checksumGenerator, Request request)
+    public GoogleClosureMinimizer(Logger logger, OperationTracker tracker, AssetChecksumGenerator
checksumGenerator, Request request,
+                                  @Symbol(WebResourcesSymbols.COMPILATION_LEVEL)
+                                  CompilationLevel compilationLevel)
     {
         super(logger, tracker, checksumGenerator, "text/javascript");
         this.request = request;
+        this.compilationLevel = compilationLevel;
     }
 
     @Override
@@ -66,6 +72,9 @@ public class GoogleClosureMinimizer extends AbstractMinimizer
         // Don't bother to pool the Compiler
 
         CompilerOptions options = new CompilerOptions();
+
+        compilationLevel.setOptionsForCompilationLevel(options);
+
         options.setCodingConvention(new ClosureCodingConvention());
         options.setOutputCharset(OUTPUT_CHARSET);
         options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING);

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/87832dd4/tapestry-webresources/src/main/java/org/apache/tapestry5/webresources/WebResourcesSymbols.java
----------------------------------------------------------------------
diff --git a/tapestry-webresources/src/main/java/org/apache/tapestry5/webresources/WebResourcesSymbols.java
b/tapestry-webresources/src/main/java/org/apache/tapestry5/webresources/WebResourcesSymbols.java
index 9f0901b..257d1eb 100644
--- a/tapestry-webresources/src/main/java/org/apache/tapestry5/webresources/WebResourcesSymbols.java
+++ b/tapestry-webresources/src/main/java/org/apache/tapestry5/webresources/WebResourcesSymbols.java
@@ -21,4 +21,13 @@ public class WebResourcesSymbols
      * It is common to set this to {@code target/asset-cache} during development.
      */
     public static final String CACHE_DIR = "tapestry.compiled-asset-cache-dir";
+
+    /**
+     * Defines the level at which the Google Closure compiler operations, as per
+     * {@link com.google.javascript.jscomp.CompilationLevel}.  The default is "WHITESPACE_ONLY",
though
+     * "SIMPLE_OPTIMIZATIONS" should also work. Advanced optimizations will likely not work,
as Tapestry's more
+     * incremental approach to JavaScript (including the use of jQuery and jQuery plugins)
is not compatible
+     * with Closure.
+     */
+    public static final String COMPILATION_LEVEL  = "tapestry.closure-compiler-level";
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/87832dd4/tapestry-webresources/src/main/java/org/apache/tapestry5/webresources/modules/WebResourcesModule.java
----------------------------------------------------------------------
diff --git a/tapestry-webresources/src/main/java/org/apache/tapestry5/webresources/modules/WebResourcesModule.java
b/tapestry-webresources/src/main/java/org/apache/tapestry5/webresources/modules/WebResourcesModule.java
index af452c0..7a716e4 100644
--- a/tapestry-webresources/src/main/java/org/apache/tapestry5/webresources/modules/WebResourcesModule.java
+++ b/tapestry-webresources/src/main/java/org/apache/tapestry5/webresources/modules/WebResourcesModule.java
@@ -14,6 +14,7 @@ package org.apache.tapestry5.webresources.modules;
 
 import com.github.sommeri.less4j.LessCompiler;
 import com.github.sommeri.less4j.core.parser.AntlrException;
+import com.google.javascript.jscomp.CompilationLevel;
 import org.apache.tapestry5.MarkupWriter;
 import org.apache.tapestry5.internal.webresources.*;
 import org.apache.tapestry5.ioc.MappedConfiguration;
@@ -56,6 +57,7 @@ public class WebResourcesModule
     public static void setupDefaultCacheDirectory(MappedConfiguration<String, Object>
configuration)
     {
         configuration.add(WebResourcesSymbols.CACHE_DIR, "${java.io.tmpdir}/tapestry-asset-cache");
+        configuration.add(WebResourcesSymbols.COMPILATION_LEVEL, CompilationLevel.WHITESPACE_ONLY);
     }
 
 


Mime
View raw message