Revert "Remove unintended changes from last commit"
This reverts commit 1ba806b185
.
This commit is contained in:
parent
2670d94c6a
commit
80e5513918
|
@ -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")
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,10 @@
|
|||
<level value="debug" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.web.servlet.resource">
|
||||
<level value="trace" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="warn" />
|
||||
|
|
Loading…
Reference in New Issue