Giter VIP home page Giter VIP logo

lesscss-java's Introduction

Official LESS CSS Compiler for Java

Latest release 1.7.0.1.1 - The 1.1 release that is compatible with less 1.7.0

LESS CSS Compiler for Java is a library to compile LESS sources to CSS stylesheets.

The compiler uses Rhino, Envjs (simulated browser environment written in JavaScript), and the official LESS JavaScript compiler.

Look at the simple example below to compile LESS to CSS:

// Instantiate the LESS compiler
LessCompiler lessCompiler = new LessCompiler();

// Instantiate the LESS compiler with some compiler options
LessCompiler lessCompiler = new LessCompiler(Arrays.asList("--relative-urls", "--strict-math=on"));

// Compile LESS input string to CSS output string
String css = lessCompiler.compile("@color: #4D926F; #header { color: @color; }");

// Or compile LESS input file to CSS output file
lessCompiler.compile(new File("main.less"), new File("main.css"));

LessCompiler is thread safe. In other words, an application only needs one LessCompiler that it can reuse whenever necessary.

To learn more about LESS, please see http://lesscss.org/.

Getting Started

Maven users should add the library using the following dependency:

<dependency>
  <groupId>org.lesscss</groupId>
  <artifactId>lesscss</artifactId>
  <version>1.7.0.1.1</version>
</dependency>

(lesscss-java is in the Maven Central repository.)

Non-Maven users should download the latest version and add it to the project's classpath. Also the following dependencies are required:

If SLF4J is present in the classpath, it will be used for logging.

Compatibility

The LESS CSS Compiler for Java contains all LESS compatibility tests. All tests pass, except the @import test case which fails partially as the compiler does not support the media query import feature (yet).

The project also contains integration tests for compiling the Twitter Bootstrap (http://twitter.github.com/bootstrap/) library. If you are using another 3th party LESS library you want to be added to the integration tests, just create a issue and provide a link to the library.

Support

Have a question, or found an issue? Just create a issue: https://github.com/marceloverdijk/lesscss-java/issues

Building From Source

Can be built with Maven 2.2.x (or later?) by using the following commands:

mvn package

or, to install into your local Maven repository:

mvn install

You may also wish to build API Documentation:

mvn javadoc:javadoc

Authors

Marcel Overdijk

Craig Andrews

Christophe Popov

Copyright and License

Copyright 2012 Marcel Overdijk

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.

lesscss-java's People

Contributors

4ntoin3 avatar apechinsky avatar candrews avatar cedmail avatar cpopov avatar davidmc24 avatar dhaber avatar emecell avatar esamson avatar msgilligan avatar sandroboehme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lesscss-java's Issues

the picture is not right when using Spoon.screenshot

in instrument test project ,take picture using calss spoon-cient.jar to take a screenshot, but the picture is aways is start app picture, not the picture in the process running in app.just like below:

device-2014-11-05-212035

my code:
hotellistpage.addFavourate(hotle);
solo.clickOnText("我的收藏");

    getInstrumentation().waitForIdleSync();
    Spoon.screenshot(getActivity(), "isSavaInFavourate");

    personlcenter.isSavaInFavourate(hotle);
    personlcenter.back();

envirorment:
spoon-client-1.1.1.jar
robotium-solo-4.0.jar

please let me know why ASAP?

thanks very much!

Update for less 1.4

Actually my project is currently using less 1.4 @runtime and want to move the templates to compile @build time. I was looking at this plugin for this purpose only to realise that it works on 1.3.3 less.

So is there any plan to move it 1.4?

IllegalAccessError

I can reproduce the error below when I deploy to heroku (but not on my own machine). I would really appreciate any input on this, as I am not at all sure how to resolve this issue. It seems to be related to the optimisation, so I wonder if a suitable solution would be to make the optimisation level parameterisable?

java.lang.IllegalAccessError: tried to access method org.mozilla.classfile.ClassFileWriter.getLabelPC(I)I from class org.mozilla.javascript.optimizer.BodyCodegen$ExceptionManager
        at org.mozilla.javascript.optimizer.BodyCodegen$ExceptionManager.endCatch(Codegen.java:4051)
        at org.mozilla.javascript.optimizer.BodyCodegen$ExceptionManager.removeHandler(Codegen.java:3952)
        at org.mozilla.javascript.optimizer.BodyCodegen.visitTryCatchFinally(Codegen.java:3705)
        at org.mozilla.javascript.optimizer.BodyCodegen.generateStatement(Codegen.java:1897)
        at org.mozilla.javascript.optimizer.BodyCodegen.generateStatement(Codegen.java:1873)
        at org.mozilla.javascript.optimizer.BodyCodegen.generateStatement(Codegen.java:1858)
        at org.mozilla.javascript.optimizer.BodyCodegen.generateBodyCode(Codegen.java:1289)
        at org.mozilla.javascript.optimizer.Codegen.generateCode(Codegen.java:306)
        at org.mozilla.javascript.optimizer.Codegen.compileToClassFile(Codegen.java:166)
        at org.mozilla.javascript.optimizer.Codegen.compile(Codegen.java:75)
        at org.mozilla.javascript.Context.compileImpl(Context.java:2377)
        at org.mozilla.javascript.Context.compileReader(Context.java:1296)
        at org.lesscss.LessCompiler.init(LessCompiler.java:289)
        at org.lesscss.LessCompiler.compile(LessCompiler.java:351)
        at org.lesscss.LessCompiler.compile(LessCompiler.java:444)

LESS 2.x

Do you have any intention to support current versions of LESS?

Mathematical operations do not work on rem units

I'm attempting to build a mixin for outputting rem units with a pixel fallback, basically:

.margin-top(@size: 1) {
    margin-top: @size * 16px;
    margin-top: @size * 1rem;
}

However the CSS output is:

margin-top: 16px;
margin-top: 1 rem;

Note the space between 1 and rem which makes the rule invalid.

I have tried a couple of other ways of achieving the same result such as @size + rem or ~"@{size}rem" with no success.

Classpath imports

A simple feature request with a not-so-simple solution (I'm guessing); I would like to be able to do the following:

@import "classpath:my/package/name/myfile.less";

invalid option modify-var or global-var

I want to use the "--modify-var" less option in my code, but i m not able to use it. It always give the message: "invalid option modify-var". Same happens for "--global-var" less option. Below is the code snippet

...
List list = new ArrayList();
list.add("--modify-var="base=#400854"");
LessCompiler lesscompiler = new LessCompiler();
lesscompiler.setOptions(list);
try {
String css = lesscompiler.compile();
...

Less file:

@base: #f938ab;
.box-shadow(@Style, @c) when (iscolor(@c)) {
-webkit-box-shadow: @Style @c;
box-shadow: @Style @c;
}
.box-shadow(@Style, @Alpha: 50%) when (isnumber(@Alpha)) {
.box-shadow(@Style, rgba(0, 0, 0, @Alpha));
}
.box {
color: saturate(@base, 5%);
border-color: lighten(@base, 30%);
div { .box-shadow(0 0 5px, 30%) }
}

Is there no support for these options or am i doing it wrong?

Rhino conflict with YUI Compressor

I ran into this issue when I started using lesscss java compiler - yui/yuicompressor#161. My module is already using YUI Compressor. Any pointers on how to have both co-exist? Is there a way lesscss-java can work with an alternate of Rhino?

Incorrect line number for errors when using imports

When compiling a file that @imports another LESS file, lesscss-java reports the wrong line number for syntax errors.

For example, suppose I have the following files:

parent.less

@import "include.less";

body { !@#$% syntax error ^&*) }

include.less

.some-mixin ( @param ) {
    /* ... */
}

.another-mixin ( @param ) {
    /* ... */
}

lesscss-java throws a LessException with the error message "Syntax Error on line 9" when the error is really on line 3.

Looking through the source code, it appears that this behavior is the result of concatenating the parent file with all of its imports in LessSource.resolveImports() (LessSource.java, line 147, which gets fed in to LessCompiler.java, line 302).

Is there a technical reason for this design choice? It would be really nice if we could let less.js take care of resolving imports and reporting the correct line number for syntax errors.

(Credit goes to micmcg for pointing this out.)

Thanks!

Contributors wanted

Hi. It looks like nobody has free time for this project. The current snapshot is broken after several merged pull requests. Plase talk to the project owner (Marcel) if you want to become a comitter. Thank you

Versions consistent with less.js

I suggest to change version pattern to version of included less.js.
For example current version 1.3.1 contains less.js 1.3.0 and 1.3.2-SNAPSHOT contains less.js 1.3.1 which is very confusing.
Maybe another minor subversion colud be added to distinguish between different versions with the same less.js (e.g. 1.3.1.x for less.js 1.3.1)

Adding the ability to use --include-path option at the compilation

Hi.

Currently, we can set the --include-path option, like every options, before calling LessCompiler#init().

I would like to change it when I compile a file, without calling LessCompiler#init() again, because of its performances cost.

Actually what I really need is a new method like this:

public synchronized String compile(File input, String name, List<String> paths) throws LessException {
}

Thanks,

Guillaume

org.lesscss.LessException: org.mozilla.javascript.EcmaError: TypeError: Cannot find function bind in object

I got this error always in my mac
I tried with different java versions, different rhino versions, even tried to upgrade my os to OS X Yosemite. Nothing helps.
Using lessc command line (npm) works.

org.lesscss.LessException: org.mozilla.javascript.EcmaError: TypeError: Cannot find function bind in object
  function _math(fn, unit, n) {
      if (!(n instanceof tree.Dimension)) {
          throw {type:"Argument", message:"argument must be a number"};
      }
      if (unit == null) {
          unit = n.unit;
      } else {
          n = n.unify();
      }
      return new (tree.Dimension)(fn(parseFloat(n.value)), unit);
  }
  . (jar:file:.../lesscss-1.7.0.1.1.jar!/META-INF/less-rhino-1.7.0.js#2926)

Improve Extendability

Loading less code is bound very hard to files.

This patch is backward compatible and allows to plug in a custom content resolver, for example to load content from inputstreams.

Error with background shorthand property

If the CSS background shorthand property is used and includes position and size values lesscss-java throws a ClassCastException:

for example - background: url(@url_var) top / cover no-repeat;

output shows:
java.lang.ClassCastException: org.mozilla.javascript.ConsString cannot be cast to java.lang.String at org.lesscss.LessCompiler.compile(LessCompiler.java:251)

1.6.1 release :: preparation

In a week I would like to start releasing the 1.6.1 version of lesscss-java to Maven Central. In addition to the current code base it is planned to contain at least the fixes for #43 and #42 supporting Less 1.6.1 to make it compatible with Bootstrap 3.1.
If you want to have your fix or feature containted in this release please contribute.
I will ask the committer what pull request to merge with the code base and only release those that have no veto.

Cheers,

Sandro

@import doesn't work when compiler ran on string

I created a simple LessCss filter for webutilities: http://code.google.com/p/webutilities/issues/detail?id=46 but unfortunately, when using LessCompiler.compile(String data) @imports don't work.

When a relative path is specified, I see this error:
org.lesscss.LessException: Couldn't load undefinedvariables.less (0)
That's understandable, obviously the import doesn't know where the path is relative from

However changing '@ import' to the full path still doesn't work:
org.lesscss.LessException: Couldn't load file:///full/path/to/file/css/variables.less (undefined)

I think it comes from envjs returning a different status for file:/// paths than browsers, the xhs.status is undefined even though the file was loaded properly (was able to hack less.js to make it ignore the return status and it worked).

If this bug can be fixed, a great enhancement would be a new function in LessCompiler:
LessCompiler.compile(String data, URL basePath); so imports would more easily work when processing data in a servlet context like the filter does.

Exception on every LESS code

Using tomcat 8.0.32 this is my code:

  try {
  	return lessCompiler.compile("");
  } catch (LessException e) {
  	byte[] bytes = lesscss.getBytes();
  	LOG.log(Level.WARNING, "Could not compile less: '" + lesscss + "' (bytes: " + Arrays.toString(bytes) + ")",
  			e);
  	throw e;
  }

I got this exception on an empty string (""):

04-May-2018 18:40:36.549 WARNING [ajp-nio-8009-exec-8] com.sotacms.server.cms.extra.service.LessCssTemplateProcessor.generateCSS Could not compile less: '' (bytes: [])
org.lesscss.LessException: java.lang.StringIndexOutOfBoundsException: String index out of range: 3
at org.lesscss.LessCompiler.compile(LessCompiler.java:426)
at org.lesscss.LessCompiler.compile(LessCompiler.java:330)
at org.lesscss.LessCompiler.compile(LessCompiler.java:312)
at com.sotacms.server.cms.extra.service.LessCssTemplateProcessor.generateCSS(LessCssTemplateProcessor.java:38)
at com.sotacms.server.cms.extra.share.template.TemplateShareController.upload(TemplateShareController.java:147)
at com.sotacms.server.cms.extra.share.template.TemplateShareController$$FastClassBySpringCGLIB$$249cd8f.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:718)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
at com.sotacms.server.cms.extra.share.template.TemplateShareController$$EnhancerBySpringCGLIB$$e117e0a3.upload()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:775)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:965)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:867)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:841)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:868)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 3
at java.lang.String.charAt(String.java:658)
at org.apache.catalina.loader.WebappClassLoaderBase.filter(WebappClassLoaderBase.java:2780)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1253)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1142)
at org.mozilla.javascript.Kit.classOrNull(Kit.java:60)
at org.mozilla.javascript.NativeJavaPackage.getPkgProperty(NativeJavaPackage.java:127)
at org.mozilla.javascript.NativeJavaPackage.get(NativeJavaPackage.java:82)
at org.mozilla.javascript.NativeJavaTopPackage.init(NativeJavaTopPackage.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.mozilla.javascript.ScriptableObject.buildClassCtor(ScriptableObject.java:1225)
at org.mozilla.javascript.LazilyLoadedCtor.buildValue0(LazilyLoadedCtor.java:105)
at org.mozilla.javascript.LazilyLoadedCtor.access$000(LazilyLoadedCtor.java:18)
at org.mozilla.javascript.LazilyLoadedCtor$1.run(LazilyLoadedCtor.java:90)
at java.security.AccessController.doPrivileged(Native Method)
at org.mozilla.javascript.LazilyLoadedCtor.buildValue(LazilyLoadedCtor.java:86)
at org.mozilla.javascript.LazilyLoadedCtor.init(LazilyLoadedCtor.java:66)
at org.mozilla.javascript.ScriptableObject$GetterSlot.getValue(ScriptableObject.java:307)
at org.mozilla.javascript.ScriptableObject.get(ScriptableObject.java:456)
at org.mozilla.javascript.IdScriptableObject.get(IdScriptableObject.java:329)
at org.mozilla.javascript.ImporterTopLevel.get(ImporterTopLevel.java:96)
at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:2184)
at org.mozilla.javascript.ScriptRuntime.topScopeName(ScriptRuntime.java:1824)
at org.mozilla.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1791)
at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1733)
at org.mozilla.javascript.gen.jar_file__usr_local_share_apache_tomcat_8_0_32_sotacms_ROOT_WEB_INF_lib_lesscss_1_7_0_1_1_jar__META_INF_less_rhino_1_7_0_js_1._c_anonymous_3(jar:file:/usr/local/share/apache-tomcat-8.0.32/sotacms/ROOT/WEB-INF/lib/lesscss-1.7.0.1.1.jar!/META-INF/less-rhino-1.7.0.js:24)
at org.mozilla.javascript.gen.jar_file__usr_local_share_apache_tomcat_8_0_32_sotacms_ROOT_WEB_INF_lib_lesscss_1_7_0_1_1_jar__META_INF_less_rhino_1_7_0_js_1.call(jar:file:/usr/local/share/apache-tomcat-8.0.32/sotacms/ROOT/WEB-INF/lib/lesscss-1.7.0.1.1.jar!/META-INF/less-rhino-1.7.0.js)
at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)
at org.mozilla.javascript.gen.jar_file__usr_local_share_apache_tomcat_8_0_32_sotacms_ROOT_WEB_INF_lib_lesscss_1_7_0_1_1_jar__META_INF_less_rhino_1_7_0_js_1._c_anonymous_2(jar:file:/usr/local/share/apache-tomcat-8.0.32/sotacms/ROOT/WEB-INF/lib/lesscss-1.7.0.1.1.jar!/META-INF/less-rhino-1.7.0.js:23)
at org.mozilla.javascript.gen.jar_file__usr_local_share_apache_tomcat_8_0_32_sotacms_ROOT_WEB_INF_lib_lesscss_1_7_0_1_1_jar__META_INF_less_rhino_1_7_0_js_1.call(jar:file:/usr/local/share/apache-tomcat-8.0.32/sotacms/ROOT/WEB-INF/lib/lesscss-1.7.0.1.1.jar!/META-INF/less-rhino-1.7.0.js)
at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)
at org.mozilla.javascript.gen.jar_file__usr_local_share_apache_tomcat_8_0_32_sotacms_ROOT_WEB_INF_lib_lesscss_1_7_0_1_1_jar__META_INF_less_rhino_1_7_0_js_1._c_script_0(jar:file:/usr/local/share/apache-tomcat-8.0.32/sotacms/ROOT/WEB-INF/lib/lesscss-1.7.0.1.1.jar!/META-INF/less-rhino-1.7.0.js:21)
at org.mozilla.javascript.gen.jar_file__usr_local_share_apache_tomcat_8_0_32_sotacms_ROOT_WEB_INF_lib_lesscss_1_7_0_1_1_jar__META_INF_less_rhino_1_7_0_js_1.call(jar:file:/usr/local/share/apache-tomcat-8.0.32/sotacms/ROOT/WEB-INF/lib/lesscss-1.7.0.1.1.jar!/META-INF/less-rhino-1.7.0.js)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
at org.mozilla.javascript.gen.jar_file__usr_local_share_apache_tomcat_8_0_32_sotacms_ROOT_WEB_INF_lib_lesscss_1_7_0_1_1_jar__META_INF_less_rhino_1_7_0_js_1.call(jar:file:/usr/local/share/apache-tomcat-8.0.32/sotacms/ROOT/WEB-INF/lib/lesscss-1.7.0.1.1.jar!/META-INF/less-rhino-1.7.0.js)
at org.lesscss.LessCompiler.compile(LessCompiler.java:383)
... 51 more

No matter what code I insert, always the SAME exception.

Call for contributors

I see people raising issues and providing patches.
I' not working on LESS at the moment and don't have time to actively support this lib.

Therefore I would like to make a call for extra contributors. to actively continue this project.
Based on the feedback and questions I get I think there is added value for this project.

UTF-8 with bom problem

Hello. Less files in intellij idea have extension utf-8 with bom. And if I want to import another .less file at the beginning of file, throws exception. May be it is problem of file's format, but if it is possible, please, add support of utf-8 with bom. Thanks

Bootstrap 3.1 vs. Less 1.6.x

The latest Bootstrap-Update 3.1 announced that they switched from Recess to grunt-contrib-less as a compiler. So they now can use Less 1.6.x.

Will this Project be able to support Less 1.6.x?
If yes - when could this be available?

Thanks in advance

java.io.FileNotFoundException when @import name ends in `*less`

I have a file named frameless.less, but when I do

@import "frameless";

I get

java.io.FileNotFoundException: File /Users/esamson/ ... /frameless not found.
     at org.lesscss.LessSource.<init>(LessSource.java:59)
     at org.lesscss.LessSource.resolveImports(LessSource.java:145)
     at org.lesscss.LessSource.<init>(LessSource.java:63)
    ...

Workaround is to say

@import "frameless.less";

But it would be nicer to be able to omit the .less extension, which works fine when just using less.js.

Cannot find function bind in object function _math

Hi guys, I tryed run my project out of IDE (Eclipse) and throws error below.
org.lesscss.LessException: org.mozilla.javascript.EcmaError: TypeError: Cannot find function bind in object
This error happens only with ES5 methods.
I don't understand why, because I'm using the latest Rhino version and when I run from Eclipse I don't have problems.

I'm using Java 7.
I know that Eclipse JRE is different of Oracle JRE.
Someone know's what happens ? To me seems like java get an old Rhino included on JDK and not the library imported to project.

1.6.1.1.0 release

A new release is available now at Maven Central.
It's the 1.0 release for Less 1.6.1

It contains the pull request of #42 and thus also fixes #43.

As I don't have commit rights here (details here: #41 (comment)) I had to release my fork of lesscss-java. It is de.sandroboehme.lesscss:lesscss:1.6.1.1.0 from https://github.com/sandroboehme/lesscss-java.
I don't intend to surpass org.lesscss I just need a released version of this artifact for Less 1.6.x to allow my users to have an out of the box compilation of my Less sources for my Bootstrap 3 project.

Less.js 1.7.1

just notifying that less.js 1.7.1 have been released

LessSource.getImports() only returns imports with type (css), (less) or none set

Hi,

I use the LessSource.getImports method to build up a dependency tree of Less files. Now I switched from Less 1.3.3

@import mixins.less

to Less 1.7

@import (reference) mixins.less

Sadly after this change those imports are not being recognized as Imports anymore.
This is due to the Regex Pattern defined in LessSource.java#45

    /**
     * The <code>Pattern</code> used to match imported files.
     */
    private static final Pattern IMPORT_PATTERN = Pattern.compile("^(?!\\s*//\\s*).*(@import\\s+(url\\(|\\((less|css)\\))?\\s*(\"|')(.+)\\s*(\"|')(\\))?(.*);).*$", MULTILINE);

There are to possibilities to solve this.

  1. Add the missing import directives (reference, inline, once)
  2. Add another function, that returns all "non standard" Imports (which would be: reference, inline, multiple). Anyway "once" would be still missing in the regular .getImports.

Personally, I would go for option 1, as it is - what I believe - is expected behaviour. An import is an import and should therefore be returned. Anyway you should then account for the "multiple" directive and only return the file once in the Map.

Brgds

Jan

Make LessCompiler thread safe

Right now, the LessCompiler instance cannot be reused between threads. It also doesn't call Context.exit(), so it doesn't detach from the thread it's on. These 2 problems cause terrible performance and wasted memory when LessCompiler is used on application servers.

I found a similar project that does handle multithreading well: it only initializes rhino once, loads the scripts, and reuses the scope so that the scripts don't need to be re-evaluated for every thread. This drastically improves performance and reduces memory use. We may want to use it as a reference in improving this project: https://github.com/ultraq/lesscss-filter/blob/master/Java/nz/net/ultraq/web/lesscss/LessCSSProcessor.java

rhino1_7R4 support - 1 line change required

rhino1_7R4 is the current version of Rhino.

change line 251 in LessCompiler.java from:
String message = (String)ScriptableObject.getProperty(value, "message");
to:
String message = ScriptableObject.getProperty(value, "message").toString();

Single or Double Quotes around imports

Both should be supported. The following two-line diff works:

     /**
      * The <code>Pattern</code> used to match imported files.
      */
-    private static final Pattern IMPORT_PATTERN = Pattern.compile("^(?!\\s*//\\s*)@import\\s+(url\\()?\\s*\"(.+)\\s*\"(\\))?\\s*;.*$", MULTILINE);
+    private static final Pattern IMPORT_PATTERN = Pattern.compile("^(?!\\s*//\\s*)@import\\s+(url\\()?\\s*(\"|')(.+)\\s*(\"|')(\\))?\\s*;.*$", MULTILINE);

     private File file;
     private String content;
     private void resolveImports() throws FileNotFoundException, IOException {
         Matcher importMatcher = IMPORT_PATTERN.matcher(normalizedContent);
         while (importMatcher.find()) {
-            String importedFile = importMatcher.group(2);
+            String importedFile = importMatcher.group(3);
             importedFile = importedFile.matches(".*\\.(le?|c)ss$") ? importedFile : importedFile + ".less";
             boolean css = importedFile.matches(".*css$");
             if (!css) {

1.7.0.1.0 Release

As promised I'm now working on syncing my fork (de.sandroboehme.lesscss:lesscss:1.6.1.1.0 from https://github.com/sandroboehme/lesscss-java) back to this project.

The next version will be org.lesscss:lesscss:1.7.0.1.0 as it is the 1.0 release for less 1.7.0 (Rhino based).

The currently pushed code fixes the following issues:

  • Less 1.7.0 support
  • #42 (Add ability to use any parameter supported by less.js)
  • #43 (Bootstrap 3.1 vs. Less 1.6.x)
  • sandroboehme/lesscss-maven-plugin#1 (Error message in the output and not in the Exception)
    This last issue is currently fixed directly in the rhino-lessc.js file. But the fix has been committed to less.js in less/less.js#1956. In the next release of rhino-lessc.js it should be included and no manual fix should be needed.
  • #15 (Added shading for commons.io)
    This rewrites org.apache.commons.io to org.lesscss.deps.org.apache.commons.io.
    It avoids problems for projects that use that library in other versions. Please see #15 for details and discussion.

You can now test the code by running the automatic tests and by installing and trying it. Please let me know if everything works fine or if there are problems that prevent a release. I will not start a release in the next week to provide time for testing.

Best,

Sandro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.