Skip to content
This repository was archived by the owner on Jan 9, 2019. It is now read-only.

Commit 3ffb30c

Browse files
author
Sandro Boehme
committed
fixed #15 and Maven test setup
1 parent a5eaf1b commit 3ffb30c

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
*.iml
66
*.ipr
77
target/
8+
dependency-reduced-pom.xml

pom.xml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<groupId>org.apache.commons</groupId>
3737
<artifactId>commons-lang3</artifactId>
3838
<version>3.1</version>
39+
<scope>test</scope>
3940
</dependency>
4041
<dependency>
4142
<groupId>org.mockito</groupId>
@@ -82,6 +83,18 @@
8283

8384
<build>
8485
<plugins>
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-surefire-plugin</artifactId>
89+
<version>2.17</version>
90+
<dependencies>
91+
<dependency>
92+
<groupId>org.apache.maven.surefire</groupId>
93+
<artifactId>surefire-junit47</artifactId>
94+
<version>2.17</version>
95+
</dependency>
96+
</dependencies>
97+
</plugin>
8598
<plugin>
8699
<groupId>org.apache.maven.plugins</groupId>
87100
<artifactId>maven-compiler-plugin</artifactId>
@@ -156,7 +169,38 @@
156169
<version>1.0</version>
157170
</signature>
158171
</configuration>
159-
</plugin>
172+
</plugin>
173+
<plugin>
174+
<groupId>org.apache.maven.plugins</groupId>
175+
<artifactId>maven-shade-plugin</artifactId>
176+
<version>2.2</version>
177+
<executions>
178+
<execution>
179+
<phase>package</phase>
180+
<goals>
181+
<goal>shade</goal>
182+
</goals>
183+
<configuration>
184+
<artifactSet>
185+
<excludes>
186+
<exclude>org.mozilla:rhino</exclude>
187+
</excludes>
188+
</artifactSet>
189+
<relocations>
190+
<relocation>
191+
<pattern>org.apache.commons.io</pattern>
192+
<shadedPattern>internaldeps.org.apache.commons.io</shadedPattern>
193+
</relocation>
194+
<relocation>
195+
<pattern>org.slf4j</pattern>
196+
<shadedPattern>internaldeps.org.slf4j</shadedPattern>
197+
</relocation>
198+
</relocations>
199+
<minimizeJar>true</minimizeJar>
200+
</configuration>
201+
</execution>
202+
</executions>
203+
</plugin>
160204
</plugins>
161205
</build>
162206

src/main/java/org/lesscss/LessCompiler.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,19 @@
1919
import java.io.IOException;
2020
import java.io.InputStream;
2121
import java.io.InputStreamReader;
22-
import java.io.OutputStreamWriter;
2322
import java.io.PrintStream;
24-
import java.io.PrintWriter;
2523
import java.io.SequenceInputStream;
2624
import java.net.URL;
2725
import java.util.ArrayList;
28-
import java.util.Arrays;
2926
import java.util.Collections;
3027
import java.util.List;
3128

3229
import org.apache.commons.io.FileUtils;
33-
import org.apache.commons.lang3.StringUtils;
3430
import org.lesscss.logging.LessLogger;
3531
import org.lesscss.logging.LessLoggerFactory;
3632
import org.mozilla.javascript.Context;
3733
import org.mozilla.javascript.Function;
3834
import org.mozilla.javascript.JavaScriptException;
39-
import org.mozilla.javascript.Script;
4035
import org.mozilla.javascript.Scriptable;
4136
import org.mozilla.javascript.ScriptableObject;
4237
import org.mozilla.javascript.tools.shell.Global;
@@ -332,7 +327,7 @@ public String compile(String input, String name) throws LessException {
332327
tempFile = File.createTempFile("tmp", "less.tmp");
333328
FileUtils.writeStringToFile(tempFile, input, this.encoding);
334329

335-
return compile( tempFile, "<inline>");
330+
return compile( tempFile, name);
336331
} catch (IOException e) {
337332
throw new LessException(e);
338333

@@ -391,7 +386,7 @@ public synchronized String compile(File input, String name) throws LessException
391386
logger.debug("Finished compilation of LESS source in %,d ms.", System.currentTimeMillis() - start );
392387
}
393388

394-
return StringUtils.isNotBlank(this.encoding) ? out.toString(encoding) : out.toString();
389+
return this.encoding != null && !this.encoding.equals("") ? out.toString(encoding) : out.toString();
395390
}
396391
catch (Exception e) {
397392
if (e instanceof JavaScriptException) {

0 commit comments

Comments
 (0)