• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CompilationException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.bit3.jsass.CompilationException的典型用法代码示例。如果您正苦于以下问题:Java CompilationException类的具体用法?Java CompilationException怎么用?Java CompilationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CompilationException类属于io.bit3.jsass包,在下文中一共展示了CompilationException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getCSS

import io.bit3.jsass.CompilationException; //导入依赖的package包/类
@GET
@Path("{fileName:.+}")
@Produces("text/css")
public Response getCSS(@PathParam("fileName") String name, @Context Request request) {
    try {
        MCRServletContextResourceImporter importer = new MCRServletContextResourceImporter(context);
        Optional<String> cssFile = MCRSassCompilerManager.getInstance()
            .getCSSFile(name, Stream.of(importer).collect(Collectors.toList()));

        if (cssFile.isPresent()) {
            CacheControl cc = new CacheControl();
            cc.setMaxAge(SECONDS_OF_ONE_DAY);

            String etagString = MCRSassCompilerManager.getInstance().getLastMD5(name).get();
            EntityTag etag = new EntityTag(etagString);

            Response.ResponseBuilder builder = request.evaluatePreconditions(etag);
            if (builder != null) {
                return builder.cacheControl(cc).tag(etag).build();
            }

            return Response.ok().status(Response.Status.OK)
                .cacheControl(cc)
                .tag(etag)
                .entity(cssFile.get())
                .build();
        } else {
            return Response.status(Response.Status.NOT_FOUND)
                .build();
        }
    } catch (IOException | CompilationException e) {
        StreamingOutput so = (OutputStream os) -> e.printStackTrace(new PrintStream(os, true, "UTF-8"));
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(so).build();
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:36,代码来源:MCRSassResource.java


示例2: cssFromSass

import io.bit3.jsass.CompilationException; //导入依赖的package包/类
private File cssFromSass(File source) throws IOException
{
    String sourceName = source.getName();

    int lastDotIndex = sourceName.lastIndexOf(SASS_SUFFIX);
    String cssName = sourceName.substring(0, lastDotIndex) + CSS_SUFFIX;
    File cssFile = new File(source.getParentFile(), cssName);

    //ONLY FROM CACHE IF WAS MODIFIED AFTER SASS FILE
    if (cssFile.exists() && source.lastModified() <= cssFile.lastModified())
    {
        List<String> lines = IOUtils.readLines(new FileInputStream(cssFile));
        if (lines != null && !lines.isEmpty())
        {
            return cssFile;
        }
    }

    if (!cssFile.exists() && !cssFile.createNewFile())
    {
        LOG.log(Level.SEVERE, "Could not create: {0} to compile sass", cssFile.getAbsolutePath());
        return null;
    }

    Compiler compiler = new Compiler();
    Options options = new Options();//TODO: options
    try
    {
        Output output = compiler.compileFile(source.toURI(), cssFile.toURI(), options);
        IOUtils.copy(new StringReader(output.getCss()), new FileOutputStream(cssFile));

        return cssFile;
    }
    catch (CompilationException ex)
    {
        LOG.log(Level.SEVERE, "Error compiling SASS: {0}", ex.getMessage());
        return null;
    }
}
 
开发者ID:touwolf,项目名称:kasije,代码行数:40,代码来源:ResourcesManagerImpl.java


示例3: sassify

import io.bit3.jsass.CompilationException; //导入依赖的package包/类
private static void sassify(File sassFile) {
    final File outputFile = getOutputFile(sassFile, Suffix.CSS);

    final URI inputURI = sassFile.toURI();
    final URI outputURI = outputFile.toURI();

    final Compiler compiler = new Compiler();
    try {
      final Output output = compiler.compileFile(inputURI, outputURI, new Options());
      FileUtils.writeStringToFile(outputFile, output.getCss(), Default.ENCODING.toString());
      logPreprocess(sassFile, outputFile);
    } catch (CompilationException | IOException e) {
        LOG.error("Failed to preprocess SASS file", e);
    }
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:16,代码来源:MinificationUtils.java


示例4: doDeploy

import io.bit3.jsass.CompilationException; //导入依赖的package包/类
@Override
public void doDeploy(File root, String path, URL entry, MProperties config) {
	File f = new File(root, path);
	root = f.getParentFile();
	root.mkdirs();
	File out = new File(root, MFile.replaceSuffix(f.getName(), "css") );
	
	try {
		Output output = compiler.compileFile(f.toURI(), out.toURI(), options);
	} catch (CompilationException e) {
		log().e(f,e);
	}
	
}
 
开发者ID:mhus,项目名称:cherry-web,代码行数:15,代码来源:SassDeployService.java


示例5: getCompiledStylesheet

import io.bit3.jsass.CompilationException; //导入依赖的package包/类
@Override
// If checkCacheInvalidation is true and, before invocation, a cached value exists and is not up to date, we evict the cache entry. 
@CacheEvict(value = "scssService.compiledStylesheets", 
		key = "T(fr.openwide.core.wicket.more.css.scss.service.ScssServiceImpl).getCacheKey(#scope, #path)",
		beforeInvocation = true,
		condition= "#checkCacheEntryUpToDate && !(caches.?[name=='scssService.compiledStylesheets'][0]?.get(T(fr.openwide.core.wicket.more.css.scss.service.ScssServiceImpl).getCacheKey(#scope, #path))?.get()?.isUpToDate() ?: false)"
		)
// THEN, we check if a cached value exists. If it does, it is returned ; if not, the method is called. 
@Cacheable(value = "scssService.compiledStylesheets",
		key = "T(fr.openwide.core.wicket.more.css.scss.service.ScssServiceImpl).getCacheKey(#scope, #path)")
public ScssStylesheetInformation getCompiledStylesheet(Class<?> scope, String path, boolean checkCacheEntryUpToDate)
		throws ServiceException {
	String scssPath = getFullPath(scope, path);
	
	try {
		JSassScopeAwareImporter importer = new JSassScopeAwareImporter(SCOPES);
		importer.addSourceUri(scssPath);
		
		Compiler compiler = new Compiler();
		Options options = new Options();
		options.setOutputStyle(OutputStyle.EXPANDED);
		options.setIndent("\t");
		options.getImporters().add(importer);
		
		ClassPathResource scssCpr = new ClassPathResource(scssPath);
		
		Context fileContext = new StringContext(IOUtils.toString(scssCpr.getInputStream()), new URI("classpath", "/" + scssPath, null), null, options);
		Output output = compiler.compile(fileContext);
		// Write result
		ScssStylesheetInformation compiledStylesheet = new ScssStylesheetInformation(scssPath, output.getCss());
		
		for (String sourceUri : importer.getSourceUris()) {
			ClassPathResource cpr = new ClassPathResource(sourceUri);
			compiledStylesheet.addImportedStylesheet(new ScssStylesheetInformation(sourceUri, cpr.lastModified()));
		}
		
		return compiledStylesheet;
	} catch (RuntimeException | IOException | URISyntaxException | CompilationException e) {
		throw new ServiceException(String.format("Error compiling %1$s", scssPath), e);
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:42,代码来源:ScssServiceImpl.java


示例6: process

import io.bit3.jsass.CompilationException; //导入依赖的package包/类
@Override
public String process(final String filename, final String source, final Config conf, final ClassLoader loader)
    throws Exception {
  String syntax = get("syntax");
  String importer = get("importer").toString().toUpperCase();
  Function<String, URI> resolver;
  if("FILE".equals(importer)) {
    resolver = FS;
  } else {
    resolver = CP.apply(loader);
  }
  OutputStyle style = OutputStyle.valueOf(get("style").toString().toUpperCase());

  Options options = new Options();
  options.setIsIndentedSyntaxSrc("sass".equals(syntax));
  options.getImporters().add(new SassImporter(syntax, resolver));
  options.setOutputStyle(style);
  options.setIndent(get("indent"));
  options.setLinefeed(get("linefeed"));
  options.setOmitSourceMapUrl(get("omitSourceMapUrl"));
  options.setPrecision(get("precision"));
  options.setSourceComments(get("sourceComments"));

  String sourcemap = get("sourcemap");
  if ("inline".equals(sourcemap)) {
    options.setSourceMapEmbed(true);
  } else if ("file".equals(sourcemap)) {
    options.setSourceMapFile(URI.create(filename + ".map"));
  }
  try {
    URI input = URI.create(filename);
    StringContext ctx = new StringContext(source, input, null, options);
    Output output = new Compiler().compile(ctx);
    return filename.endsWith(".map") ? output.getSourceMap() : output.getCss();
  } catch (CompilationException x) {
    Matcher matcher = LOCATION.matcher(x.getErrorJson());
    Map<String, Integer> location = new HashMap<>();
    while (matcher.find()) {
      location.put(matcher.group(1), Integer.parseInt(matcher.group(2)));
    }
    int line = location.getOrDefault("line", -1);
    int column = location.getOrDefault("column", -1);
    throw new AssetException(name(),
        new AssetProblem(Optional.ofNullable(x.getErrorFile()).orElse(filename), line, column,
            x.getErrorText(), null));
  }
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:48,代码来源:Sass.java


示例7: getCSSFile

import io.bit3.jsass.CompilationException; //导入依赖的package包/类
/**
 * Gets the compiled(&amp;compressed) CSS
 *
 * @param file     the path to a .scss file. File should end with .css or .min.css (The compiler will look for the
 *                 .scss file, then compiles and decides to minify or not).
 * @param importer a additional list of importers
 * @return Optional with the compiled css as string. Empty optional if the fileName is not valid.
 * @throws CompilationException if {@link Compiler#compile(FileContext)} throws
 */
public synchronized Optional<String> getCSSFile(String file, List<Importer> importer)
    throws CompilationException, IOException {
    if (!isDeveloperMode() && fileCompiledContentMap.containsKey(file)) {
        return Optional.of(fileCompiledContentMap.get(file));
    } else {
        return Optional.ofNullable(compile(file, importer));
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:18,代码来源:MCRSassCompilerManager.java



注:本文中的io.bit3.jsass.CompilationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocationProviderStatus类代码示例发布时间:2022-05-23
下一篇:
Java Systrace类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap