当前位置: 首页>>代码示例>>Java>>正文


Java Compiler.setLoggingLevel方法代码示例

本文整理汇总了Java中com.google.javascript.jscomp.Compiler.setLoggingLevel方法的典型用法代码示例。如果您正苦于以下问题:Java Compiler.setLoggingLevel方法的具体用法?Java Compiler.setLoggingLevel怎么用?Java Compiler.setLoggingLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.jscomp.Compiler的用法示例。


在下文中一共展示了Compiler.setLoggingLevel方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
public void execute() {
  if (this.outputFile == null) {
    throw new BuildException("outputFile attribute must be set");
  }

  Compiler.setLoggingLevel(Level.OFF);

  CompilerOptions options = createCompilerOptions();
  Compiler compiler = createCompiler(options);

  JSSourceFile[] externs = findExternFiles();
  JSSourceFile[] sources = findSourceFiles();

  log("Compiling " + sources.length + " file(s) with " +
      externs.length + " extern(s)");

  Result result = compiler.compile(externs, sources, options);
  if (result.success) {
    writeResult(compiler.toSource());
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:22,代码来源:CompileTask.java

示例2: execute

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
public void execute() {
  if (this.outputFile == null) {
    throw new BuildException("outputFile attribute must be set");
  }

  Compiler.setLoggingLevel(Level.OFF);

  CompilerOptions options = createCompilerOptions();
  Compiler compiler = createCompiler(options);

  JSSourceFile[] externs = findExternFiles();
  JSSourceFile[] sources = findSourceFiles();

  log("Compiling " + sources.length + " file(s) with " +
      externs.length + " extern(s)");

  Result result = compiler.compile(externs, sources, options);
  if (result.success) {
    writeResult(compiler.toSource());
  } else {
    throw new BuildException("Compilation failed.");
  }
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:24,代码来源:CompileTask.java

示例3: invoke

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
CompiledScript invoke() throws Exception {
  Compiler compiler = new Compiler();

  compiler.setLoggingLevel( Level.OFF );

  SourceFile input = SourceFile.fromFile( srcFile );
  input.setOriginalPath( relSrcFilePath );

  Result res = compiler.compile( EMPTY_EXTERNS_SOURCE_FILE, input, options );
  if ( res.success ) {
    String name = srcFile.getName();

    code = new StringBuilder( compiler.toSource() );
    code.append( "\n//# sourceMappingURL=" ).append( name ).append( ".map" );

    sourcemap = new StringBuilder();
    SourceMap sm = compiler.getSourceMap();
    sm.appendTo( sourcemap, name );

    return this;
  }

  throw new Exception( "Failed script compilation" );
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:25,代码来源:WebjarsURLConnection.java

示例4: createCompiler

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
private Compiler createCompiler() {
    try {
        Compiler closureCompiler  = new Compiler(new PrintStream(new DiscardOutputStream(), false, "UTF-8"));
        closureCompiler.disableThreads();
        Compiler.setLoggingLevel(Level.INFO);
        return closureCompiler;
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:11,代码来源:ContentAssist.java

示例5: process

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
@Override
public void process(final Reader reader, final Writer writer) throws IOException {
    logger.debug("google closure processing...");
    final String originalJsSourceCode = IOUtils.toString(reader);
    try {
        Compiler.setLoggingLevel(Level.SEVERE);
        final Compiler compiler = new Compiler();
        final CompilerOptions compilerOptions = newCompilerOptions();
        compilationLevel.setOptionsForCompilationLevel(compilerOptions);
        //make it play nice with GAE
        compiler.disableThreads();
        compiler.initOptions(compilerOptions);

        final SourceFile input = SourceFile.fromInputStream("dummy.js", new ByteArrayInputStream(originalJsSourceCode.getBytes(soyViewConf.globalEncoding())));
        final Result result = compiler.compile(Lists.<SourceFile>newArrayList(), Lists.newArrayList(input), compilerOptions);

        logWarningsAndErrors(result);

        boolean origFallback = false;
        if (result.success) {
            final String minifiedJsSourceCode = compiler.toSource();
            if (StringUtils.isEmpty(minifiedJsSourceCode)) {
                origFallback = true;
            } else {
                writer.write(minifiedJsSourceCode);
            }
        } else {
            origFallback = true;
        }
        if (origFallback) {
            writer.write(originalJsSourceCode);
        }
    } finally {
        reader.close();
        writer.close();
    }
}
 
开发者ID:matiwinnetou,项目名称:play-soy-view,代码行数:38,代码来源:GoogleClosureOutputProcessor.java

示例6: execute

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
@Override
public void execute() {
  if (this.outputFile == null) {
    throw new BuildException("outputFile attribute must be set");
  }

  Compiler.setLoggingLevel(Level.OFF);

  CompilerOptions options = createCompilerOptions();
  Compiler compiler = createCompiler(options);

  List<SourceFile> externs = findExternFiles();
  List<SourceFile> sources = findSourceFiles();

  if (isStale() || forceRecompile) {
    log("Compiling " + sources.size() + " file(s) with " +
        externs.size() + " extern(s)");

    Result result = compiler.compile(externs, sources, options);
    if (result.success) {
      writeResult(compiler.toSource());
    } else {
      throw new BuildException("Compilation failed.");
    }
  } else {
    log("None of the files changed. Compilation skipped.");
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:29,代码来源:CompileTask.java

示例7: closureCompile

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
/**
 * Compiles the scripts from the given files into a single script using the
 * Google closure compiler. Any problems encountered are logged as warnings
 * or errors (depending on severity).
 * <p>
 * For better understanding what is going on in this method, please read
 * "Closure: The Definitve Guide" by M. Bolin. Especially chapters 12 and 14
 * explain how to use the compiler programmatically.
 */
private String closureCompile(CompilationLevel level,
		List<JavaScriptFile> inputFiles, List<JavaScriptFile> externFiles,
		ILogger logger) {

	CollectingErrorManager collectingErrorManager = new CollectingErrorManager(
			inputFiles, externFiles);
	Compiler compiler = new Compiler(collectingErrorManager);
	Compiler.setLoggingLevel(Level.OFF);

	List<JSSourceFile> defaultExterns = new ArrayList<JSSourceFile>();
	try {
		defaultExterns = CommandLineRunner.getDefaultExterns();
	} catch (IOException e) {
		logger.error(
				"Could not load closure's default externs! Probably this will prevent compilation.",
				e);
	}

	Result result = compiler.compile(
			createJSSourceFiles(externFiles, defaultExterns),
			createJSSourceFiles(inputFiles, new ArrayList<JSSourceFile>()),
			determineOptions(level));

	if (!collectingErrorManager.messages.isEmpty()) {
		logger.warn(new ListStructuredLogMessage(
				"JavaScript compilation produced "
						+ collectingErrorManager.messages.size()
						+ " errors and warnings",
				collectingErrorManager.messages, JavaScriptManager.LOG_TAG));
	}

	if (!result.success) {
		logger.error("Compilation of JavaScript code failed! Falling back to concatenated script.");
		return concatScripts(inputFiles);
	}

	return StringUtils.normalizeLineBreaks(compiler.toSource());
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:48,代码来源:ConQATJavaScriptCompiler.java

示例8: processInput

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void processInput(ITextResource input) throws ConQATException {

	NodeUtils.addToDisplayList(input, KEY);

	uniformPathToElementMap = ResourceTraversalUtils
			.createUniformPathToElementMap(input, ITextElement.class);

	group = NodeUtils.getFindingReport(input)
			.getOrCreateCategory("Google Closure")
			.getOrCreateFindingGroup("Closure Findings");

	FindingErrorManager errorManager = new FindingErrorManager();
	Compiler compiler = new Compiler(errorManager);
	Compiler.setLoggingLevel(Level.OFF);
	compiler.compile(new JSSourceFile[0], CollectionUtils.toArray(
			determineInputFiles(input), JSSourceFile.class),
			determineOptions());

	if (errorManager.hadErrors()) {
		throw new ConQATException("Closure compile error: '"
				+ errorManager.error.description + "' at "
				+ errorManager.error.sourceName + ":"
				+ errorManager.error.lineNumber);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:28,代码来源:ClosureAnalyzer.java

示例9: process

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
@Override
public String process(final String filename, final String source, final Config conf)
    throws Exception {
  final CompilerOptions copts = new CompilerOptions();
  copts.setCodingConvention(new ClosureCodingConvention());
  copts.setOutputCharset("UTF-8");
  copts.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING);
  CompilationLevel level = level(get("level"));
  level.setOptionsForCompilationLevel(copts);

  Compiler.setLoggingLevel(Level.SEVERE);
  Compiler compiler = new Compiler();
  compiler.disableThreads();
  compiler.initOptions(copts);

  List<SourceFile> externs = externs(copts);
  Result result = compiler.compile(externs,
      ImmutableList.of(SourceFile.fromCode(filename, source)), copts);
  if (result.success) {
    return compiler.toSource();
  }
  List<AssetProblem> errors = Arrays.stream(result.errors)
      .map(error -> new AssetProblem(error.sourceName, error.lineNumber, error.getCharno(),
          error.description, null))
      .collect(Collectors.toList());
  throw new AssetException(name(), errors);
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:28,代码来源:ClosureCompiler.java

示例10: compress

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
@Override
public String compress(String source) {
	
	StringWriter writer = new StringWriter();
	
	//prepare source
	List<JSSourceFile> input = new ArrayList<JSSourceFile>();
	input.add(JSSourceFile.fromCode("source.js", source));
	
	//prepare externs
	List<JSSourceFile> externsList = new ArrayList<JSSourceFile>();
	if(compilationLevel.equals(CompilationLevel.ADVANCED_OPTIMIZATIONS)) {
		//default externs
		if(!customExternsOnly) {
			try {
				externsList = getDefaultExterns();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		//add user defined externs
		if(externs != null) {
			for(JSSourceFile extern : externs) {
				externsList.add(extern);
			}
		}
		//add empty externs
		if(externsList.size() == 0) {
			externsList.add(JSSourceFile.fromCode("externs.js", ""));
		}
	} else {
		//empty externs
		externsList.add(JSSourceFile.fromCode("externs.js", ""));
	}
	
	Compiler.setLoggingLevel(loggingLevel);
	
	Compiler compiler = new Compiler();
	compiler.disableThreads();
	
	compilationLevel.setOptionsForCompilationLevel(compilerOptions);
	warningLevel.setOptionsForWarningLevel(compilerOptions);
	
	Result result = compiler.compile(externsList, input, compilerOptions);
	
	if (result.success) {
		writer.write(compiler.toSource());
	} else {
		writer.write(source);
	}

	return writer.toString();

}
 
开发者ID:ad3n,项目名称:htmlcompressor,代码行数:55,代码来源:ClosureJavaScriptCompressor.java

示例11: execute

import com.google.javascript.jscomp.Compiler; //导入方法依赖的package包/类
@Override
public void execute() {
  if (this.outputFile == null) {
    throw new BuildException("outputFile attribute must be set");
  }

  Compiler.setLoggingLevel(Level.OFF);

  CompilerOptions options = createCompilerOptions();
  Compiler compiler = createCompiler(options);

  List<SourceFile> externs = findExternFiles(options);
  List<SourceFile> sources = findSourceFiles();

  if (isStale() || forceRecompile) {
    log("Compiling " + sources.size() + " file(s) with " +
        externs.size() + " extern(s)");

    Result result = compiler.compile(externs, sources, options);

    if (result.success) {
      StringBuilder source = new StringBuilder(compiler.toSource());

      if (this.outputWrapperFile != null) {
        try {
          this.outputWrapper = Files.asCharSource(this.outputWrapperFile, UTF_8).read();
        } catch (Exception e) {
          throw new BuildException("Invalid output_wrapper_file specified.");
        }
      }

      if (this.outputWrapper != null) {
        int pos = this.outputWrapper.indexOf(CommandLineRunner.OUTPUT_MARKER);
        if (pos > -1) {
          String prefix = this.outputWrapper.substring(0, pos);
          source.insert(0, prefix);

          // end of outputWrapper
          int suffixStart = pos + CommandLineRunner.OUTPUT_MARKER.length();
          String suffix = this.outputWrapper.substring(suffixStart);
          source.append(suffix);
        } else {
          throw new BuildException("Invalid output_wrapper specified. " +
              "Missing '" + CommandLineRunner.OUTPUT_MARKER + "'.");
        }
      }

      if (result.sourceMap != null) {
        flushSourceMap(result.sourceMap);
      }
      writeResult(source.toString());
    } else {
      throw new BuildException("Compilation failed.");
    }
  } else {
    log("None of the files changed. Compilation skipped.");
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:59,代码来源:CompileTask.java


注:本文中的com.google.javascript.jscomp.Compiler.setLoggingLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。