diff --git a/build.gradle b/build.gradle
index 094daef0b28..3bfebe7dca9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -22,6 +22,7 @@ configure(allprojects) { project ->
apply plugin: "java"
apply plugin: "test-source-set-dependencies"
apply from: "${gradleScriptDir}/ide.gradle"
+ apply plugin: "maven"
[compileJava, compileTestJava]*.options*.compilerArgs = [
"-Xlint:serial",
@@ -631,6 +632,7 @@ project("spring-webmvc") {
optional("org.freemarker:freemarker:2.3.19")
optional("org.codehaus.jackson:jackson-mapper-asl:1.9.12")
optional("com.fasterxml.jackson.core:jackson-databind:2.2.0")
+ optional("org.lesscss:lesscss:1.3.3")
provided("javax.servlet:jstl:1.2")
provided("javax.servlet:javax.servlet-api:3.0.1")
provided("javax.servlet.jsp:jsp-api:2.1")
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/LessResourceTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/LessResourceTransformer.java
new file mode 100644
index 00000000000..2268a3fdde0
--- /dev/null
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/LessResourceTransformer.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed 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.
+ */
+
+package org.springframework.web.servlet.resource;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.lesscss.LessCompiler;
+import org.lesscss.LessException;
+import org.springframework.core.io.Resource;
+import org.springframework.util.StringUtils;
+
+
+/**
+ *
+ * @author Jeremy Grelle
+ * @since 4.0
+ */
+public class LessResourceTransformer implements ResourceTransformer {
+
+ private static final String LESS_EXT = "less";
+
+ private final LessCompiler compiler = new LessCompiler();
+
+
+ @Override
+ public Resource transform(Resource original) throws IOException {
+ TransformedResource transformed;
+ try {
+ String content = "";
+ if (original instanceof TransformedResource) {
+ content = ((TransformedResource) original).getContentAsString();
+ }
+ else {
+ content = this.compiler.compile(original.getFile());
+ }
+ transformed = new TransformedResource(original.getFilename().replace(
+ "." + LESS_EXT, ""), content.getBytes("UTF-8"), original.lastModified());
+ }
+ catch (LessException ex) {
+ //TODO - Nicely print out the compilation error
+ ex.printStackTrace();
+ return null;
+ }
+ return transformed;
+ }
+
+ @Override
+ public boolean willTransform(HttpServletRequest request, Resource original) {
+ return LESS_EXT.equals(StringUtils.getFilenameExtension(original.getFilename()));
+ }
+
+}
diff --git a/spring-webmvc/src/test/resources/log4j.xml b/spring-webmvc/src/test/resources/log4j.xml
index 785c094dde1..1f7f3d0980e 100644
--- a/spring-webmvc/src/test/resources/log4j.xml
+++ b/spring-webmvc/src/test/resources/log4j.xml
@@ -19,6 +19,10 @@
+
+
+
+