Package com.github.sommeri.less4j.LessCompiler

Examples of com.github.sommeri.less4j.LessCompiler.CompilationResult


  @Test
  public void fileIncludeLessFiles() throws Less4jException {
    LessCompiler compiler = new DefaultLessCompiler();
    Configuration configuration = new Configuration();
    configuration.getSourceMapConfiguration().setIncludeSourcesContent(true);
    CompilationResult compilationResult = compiler.compile(ONE_IMPORT_LESS_FILE, configuration);
   
    assertNotNull(compilationResult.getCss());
    assertNotNull(compilationResult.getSourceMap());
    assertLinksSourceMap(compilationResult.getCss(), toFullMapSuffix());
   
    SourceMapValidator validator = new SourceMapValidator(LESS_INPUT_CONTENTS);
    validator.validateSourceMap(compilationResult, new File(ONE_IMPORT_MAPDATA_WITH_LESS), URIUtils.changeSuffix(ONE_IMPORT_LESS_FILE, Constants.CSS_SUFFIX));
  }
View Full Code Here


  public void fileSelfContained() throws Less4jException {
    LessCompiler compiler = new DefaultLessCompiler();
    Configuration configuration = new Configuration();
    configuration.getSourceMapConfiguration().setIncludeSourcesContent(true);
    configuration.getSourceMapConfiguration().setInline(true);
    CompilationResult compilationResult = compiler.compile(ONE_IMPORT_LESS_FILE, configuration);
   
    assertNotNull(compilationResult.getCss());
    assertNotNull(compilationResult.getSourceMap());
    assertInlineSourceMap(compilationResult);
   
    SourceMapValidator validator = new SourceMapValidator(LESS_INPUT_CONTENTS);
    validator.validateSourceMap(compilationResult, new File(ONE_IMPORT_MAPDATA_WITH_LESS), URIUtils.changeSuffix(ONE_IMPORT_LESS_FILE, Constants.CSS_SUFFIX));
  }
View Full Code Here

  public void fileWithConfiguration() throws Less4jException {
    Configuration configuration = new Configuration();
    configuration.setCssResultLocation(new File(FAKE_CSS_RESULT_LOCATION));

    LessCompiler compiler = new DefaultLessCompiler();
    CompilationResult compilationResult = compiler.compile(ONE_IMPORT_LESS_FILE, configuration);
   
    assertNotNull(compilationResult.getCss());
    assertNotNull(compilationResult.getSourceMap());
    assertLinksSourceMap(compilationResult.getCss(), FAKE_CSS_RESULT_LINKED_MAP);
   
    SourceMapValidator validator = new SourceMapValidator(LESS_INPUT_CONTENTS);
    validator.validateSourceMap(compilationResult, new File(ONE_IMPORT_CSS_KNOWN_MAPDATA), FAKE_CSS_RESULT_FILE);
  }
View Full Code Here

  public void fileWithUrlConfiguration() throws Less4jException {
    Configuration configuration = new Configuration();
    configuration.setCssResultLocation(new LessSource.URLSource(FAKE_URL_RESULT_URL));

    LessCompiler compiler = new DefaultLessCompiler();
    CompilationResult compilationResult = compiler.compile(ONE_IMPORT_LESS_FILE, configuration);
   
    assertNotNull(compilationResult.getCss());
    assertNotNull(compilationResult.getSourceMap());
    assertLinksSourceMap(compilationResult.getCss(), FAKE_URL_RESULT_LINKED_MAP);
   
    SourceMapValidator validator = new SourceMapValidator(LESS_INPUT_CONTENTS);
    validator.validateSourceMap(compilationResult, new File(ONE_IMPORT_URL_KNOWN_MAPDATA));
  }
View Full Code Here

  protected CompilationResult compile(File lessFile, File cssOutput) throws Less4jException {
    try {
      String less = IOUtils.toString(new FileReader(lessFile));
      LessCompiler compiler = getCompiler();
      Configuration configuration = createConfiguration(cssOutput);
      CompilationResult actual = compiler.compile(new StringSource(less), configuration);
      return actual;
    } catch (IOException ex) {
      throw new RuntimeException("Can not read less file " + lessFile.getName(), ex);
    }
  }
View Full Code Here

  @Override
  public void process(final Resource resource, final Reader reader, final Writer writer)
      throws IOException {
    try {
      final LessSource lessSource = new RelativeAwareLessSource(resource, IOUtils.toString(reader), locatorFactory);
      final CompilationResult result = compiler.compile(lessSource);
      logWarnings(result);
      writer.write(result.getCss());
    } catch (final Less4jException e) {
      LOG.error("Failed to compile less resource: {}.", resource);
      for (final Problem problem : e.getErrors()) {
        LOG.error(problemAsString(problem));
      }
View Full Code Here

TOP

Related Classes of com.github.sommeri.less4j.LessCompiler.CompilationResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.