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


Java JobDescription类代码示例

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


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

示例1: executeJob

import com.google.common.css.JobDescription; //导入依赖的package包/类
private static void executeJob(
    JobDescription job, ExitCodeHandler exitCodeHandler, OutputInfo outputInfo) {
  CompilerErrorManager errorManager = new CompilerErrorManager();

  ClosureCommandLineCompiler compiler =
      new ClosureCommandLineCompiler(job, exitCodeHandler, errorManager);

  String compilerOutput = compiler.execute(outputInfo.renameFile, outputInfo.sourceMapFile);

  if (outputInfo.outputFile == null) {
    System.out.print(compilerOutput);
  } else {
    try {
      Files.asCharSink(outputInfo.outputFile, UTF_8).write(compilerOutput);
    } catch (IOException e) {
      AbstractCommandLineCompiler.exitOnUnhandledException(e, exitCodeHandler);
    }
  }
}
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:20,代码来源:ClosureCommandLineCompiler.java

示例2: createSubstitutionMap

import com.google.common.css.JobDescription; //导入依赖的package包/类
/**
 * Creates the CSS class substitution map from the provider, if any.
 * Wraps it in a substitution map that optionally prefixes all of the renamed
 * classes. Additionaly wraps in a recording substituion map which excludes a
 * blacklist of classnames and allows the map to produced as an output.
 */
private static RecordingSubstitutionMap createSubstitutionMap(
    JobDescription job) {
  if (job.cssSubstitutionMapProvider != null) {
    SubstitutionMap baseMap = job.cssSubstitutionMapProvider.get();
    if (baseMap != null) {
      SubstitutionMap map = baseMap;
      if (!job.cssRenamingPrefix.isEmpty()) {
        map = new PrefixingSubstitutionMap(baseMap, job.cssRenamingPrefix);
      }
      RecordingSubstitutionMap recording =
          new RecordingSubstitutionMap.Builder()
              .withSubstitutionMap(map)
              .shouldRecordMappingForCodeGeneration(
                  Predicates.not(Predicates.in(job.excludedClassesFromRenaming)))
              .build();
      recording.initializeWithMappings(job.inputRenamingMap);
      return recording;
    }
  }
  return null;
}
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:28,代码来源:PassRunner.java

示例3: testMixinPropagation

import com.google.common.css.JobDescription; //导入依赖的package包/类
@Test
public void testMixinPropagation() throws Exception {
  ErrorManager errorManager = new NewFunctionalTestBase.TestErrorManager(new String[0]);

  SourceCode def =
      new SourceCode(
          "def.gss", "@defmixin spriteUrl() {  background: url('sprite.png') no-repeat; }");
  SourceCode call = new SourceCode("call.gss", ".example { @mixin spriteUrl(); }");

  JobDescription job =
      new JobDescriptionBuilder()
          .addInput(def)
          .addInput(call)
          .setAllowDefPropagation(true)
          .getJobDescription();

  ClosureCommandLineCompiler compiler =
      new ClosureCommandLineCompiler(job, EXIT_CODE_HANDLER, errorManager);

  String output = compiler.execute(null /* renameFile */, null /* sourcemapFile */);

  assertThat(output).isEqualTo(".example{background:url('sprite.png') no-repeat}");
}
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:24,代码来源:ClosureCommandLineCompilerTest.java

示例4: testEmptyImportBlocks

import com.google.common.css.JobDescription; //导入依赖的package包/类
@Test

  public void testEmptyImportBlocks() throws Exception {
    // See b/29995881
    ErrorManager errorManager = new NewFunctionalTestBase.TestErrorManager(new String[0]);

    JobDescription job = new JobDescriptionBuilder()
      .addInput(new SourceCode("main.css", "@import 'common.css';"))
      .addInput(new SourceCode("common.css", "/* common */"))
      .setOptimizeStrategy(JobDescription.OptimizeStrategy.SAFE)
      .setCreateSourceMap(true)
      .getJobDescription();

    File outputDir = Files.createTempDir();
    File sourceMapFile = new File(outputDir, "sourceMap");

    String compiledCss = new ClosureCommandLineCompiler(
        job, EXIT_CODE_HANDLER, errorManager)
        .execute(null /*renameFile*/, sourceMapFile);

    // The symptom was an IllegalStateException trapped by the compiler that
    // resulted in the exit handler being called which causes fail(...),
    // so if control reaches here, we're ok.

    assertThat(compiledCss).isNotNull();
  }
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:27,代码来源:ClosureCommandLineCompilerTest.java

示例5: DefaultCommandLineCompiler

import com.google.common.css.JobDescription; //导入依赖的package包/类
/**
 * Constructs a {@code DefaultCommandLineCompiler}.
 *
 * @param job The inputs the compiler should process and the options to use.
 * @param errorManager The error manager to use for error reporting.
 */
protected DefaultCommandLineCompiler(JobDescription job,
    ExitCodeHandler exitCodeHandler, ErrorManager errorManager) {
  super(job, exitCodeHandler);
  this.errorManager = errorManager;
  this.passRunner = new PassRunner(job, errorManager);
  this.gssSourceMapGenerator = createSourceMapGenerator(job);
}
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:14,代码来源:DefaultCommandLineCompiler.java

示例6: main

import com.google.common.css.JobDescription; //导入依赖的package包/类
public static void main(String[] args) {
  ExitCodeHandler exitCodeHandler = new DefaultExitCodeHandler();
  Flags flags = parseArgs(args, exitCodeHandler);
  if (flags == null) {
    return;
  }

  JobDescription job = flags.createJobDescription();
  OutputInfo info = flags.createOutputInfo();
  executeJob(job, exitCodeHandler, info);
}
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:12,代码来源:ClosureCommandLineCompiler.java

示例7: testAllowDefPropagationDefaultsToTrue

import com.google.common.css.JobDescription; //导入依赖的package包/类
@Test

  public void testAllowDefPropagationDefaultsToTrue() throws Exception {
    ClosureCommandLineCompiler.Flags flags =
        ClosureCommandLineCompiler.parseArgs(new String[] {"/dev/null"}, EXIT_CODE_HANDLER);
    JobDescription jobDescription = flags.createJobDescription();
    assertThat(jobDescription.allowDefPropagation).isTrue();
  }
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:9,代码来源:ClosureCommandLineCompilerTest.java

示例8: parse

import com.google.common.css.JobDescription; //导入依赖的package包/类
private void parse(String styleSheet, RecordingSubstitutionMap map) {
  SourceCode input = new SourceCode("test-input", styleSheet);
  GssParser parser = new GssParser(input);
  CssTree cssTree;
  try {
    cssTree = parser.parse();
  } catch (GssParserException e) {
    throw new RuntimeException(e);
  }
  JobDescription job = new JobDescriptionBuilder().getJobDescription();
  ErrorManager errorManager = new DummyErrorManager();
  PassRunner passRunner = new PassRunner(job, errorManager, map);
  passRunner.runPasses(cssTree);
}
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:15,代码来源:RecordingSubstitutionMapTest.java

示例9: compileCss

import com.google.common.css.JobDescription; //导入依赖的package包/类
boolean compileCss(final BuildContext buildContext, Log log)
throws IOException {
  if (inputs.isEmpty()) {
    log.info("No CSS files to compile");
    return true;
  }
  log.info("Compiling " + inputs.size() + " CSS files" +
      (outputFile.isPresent() ? " to " + outputFile.get().getPath() : ""));

  JobDescription job = cssOptions.getJobDescription(
      log, inputs, substitutionMapProvider);

  final class OkUnlessNonzeroExitCodeHandler implements ExitCodeHandler {
    boolean ok = true;

    @Override
    public void processExitCode(int exitCode) {
      if (exitCode != 0) {
        ok = false;
      }
    }
  }

  OkUnlessNonzeroExitCodeHandler exitCodeHandler =
      new OkUnlessNonzeroExitCodeHandler();

  ErrorManager errorManager = new MavenCssErrorManager(buildContext);
  for (Source input : inputs) {
    buildContext.removeMessages(input.canonicalPath);
  }

  ensureParentDirectoryFor(sourceMapFile);
  ensureParentDirectoryFor(renameFile);
  ensureParentDirectoryFor(outputFile);

  String compiledCss =
      new ClosureCommandLineCompiler(job, exitCodeHandler, errorManager) {
        @Override
        public String execute(File renameOutFile, File sourceMapOutFile) {
          return super.execute(renameOutFile, sourceMapOutFile);
        }
      }
      .execute(renameFile.orNull(), sourceMapFile.orNull());
  if (compiledCss == null) {
    return false;
  }
  if (outputFile.isPresent()) {
    Files.write(compiledCss, outputFile.get(), Charsets.UTF_8);
  }
  return exitCodeHandler.ok;
}
 
开发者ID:mikesamuel,项目名称:closure-maven-plugin,代码行数:52,代码来源:CssCompilerWrapper.java

示例10: createSourceMapGenerator

import com.google.common.css.JobDescription; //导入依赖的package包/类
private GssSourceMapGenerator createSourceMapGenerator(JobDescription job) {
  if (!job.createSourceMap) {
    return new NullGssSourceMapGenerator();
  }
  return new DefaultGssSourceMapGenerator(job.sourceMapLevel);
}
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:7,代码来源:DefaultCommandLineCompiler.java

示例11: ClosureCommandLineCompiler

import com.google.common.css.JobDescription; //导入依赖的package包/类
protected ClosureCommandLineCompiler(JobDescription job,
    ExitCodeHandler exitCodeHandler, ErrorManager errorManager) {
  super(job, exitCodeHandler, errorManager);
}
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:5,代码来源:ClosureCommandLineCompiler.java

示例12: PassRunner

import com.google.common.css.JobDescription; //导入依赖的package包/类
public PassRunner(JobDescription job, ErrorManager errorManager) {
  this(job, errorManager, createSubstitutionMap(job));
}
 
开发者ID:google,项目名称:closure-stylesheets,代码行数:4,代码来源:PassRunner.java

示例13: GSSCompilerCli

import com.google.common.css.JobDescription; //导入依赖的package包/类
public GSSCompilerCli(JobDescription job, ExitCodeHandler exitCodeHandler,
		ErrorManager errorManager, LinkedHashSet<File> externs) {
	super(job, exitCodeHandler, errorManager);
}
 
开发者ID:DigiArea,项目名称:closurefx-builder,代码行数:5,代码来源:GSSCompilerCli.java

示例14: GSSCompiler

import com.google.common.css.JobDescription; //导入依赖的package包/类
public GSSCompiler(JobDescription job, ExitCodeHandler exitCodeHandler,
		ErrorManager errorManager, LinkedHashSet<File> externs) {
	super(job, exitCodeHandler, errorManager);
	// this.externs = externs;
}
 
开发者ID:DigiArea,项目名称:closurefx-builder,代码行数:6,代码来源:GSSCompiler.java

示例15: setOutputOrientation

import com.google.common.css.JobDescription; //导入依赖的package包/类
/**
 * Specify this option to perform automatic right to left conversion
 * of the input. You can choose between: LTR, RTL,
 * NOCHANGE. NOCHANGE means the input will not be changed in any way
 * with respect to direction issues. LTR outputs a sheet suitable
 * for left to right display and RTL outputs a sheet suitable for
 * right to left display. If the input orientation is different than
 * the requested output orientation, 'left' and 'right' values in
 * direction sensitive style rules are flipped. If the input already
 * has the desired orientation, this option effectively does nothing
 * except for defining GSS_LTR and GSS_RTL, respectively. The input
 * is LTR by default and can be changed with the input_orientation
 * flag.
 * <p>
 * When specified multiple times, multiple outputs are specified and
 * the {orient} can be used in the output path template to put output
 * compiled with different orientations in different output files.
 */
public void setOutputOrientation(JobDescription.OutputOrientation x) {
  outputOrientation.add(x);
}
 
开发者ID:mikesamuel,项目名称:closure-maven-plugin,代码行数:22,代码来源:CssOptions.java


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