Java Code Examples for com.google.javascript.jscomp.CompilationLevel#ADVANCED_OPTIMIZATIONS

The following examples show how to use com.google.javascript.jscomp.CompilationLevel#ADVANCED_OPTIMIZATIONS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompileTask.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the compilation level.
 * @param value The optimization level by string name.
 *     (whitespace, simple, advanced).
 */
public void setCompilationLevel(String value) {
  if ("simple".equalsIgnoreCase(value)) {
    this.compilationLevel = CompilationLevel.SIMPLE_OPTIMIZATIONS;
  } else if ("advanced".equalsIgnoreCase(value)) {
    this.compilationLevel = CompilationLevel.ADVANCED_OPTIMIZATIONS;
  } else if ("whitespace".equalsIgnoreCase(value)) {
    this.compilationLevel = CompilationLevel.WHITESPACE_ONLY;
  } else {
    throw new BuildException(
        "Unrecognized 'compilation' option value (" + value + ")");
  }
}
 
Example 2
Source File: JavaScriptCompilerMojoTest.java    From wisdom with Apache License 2.0 5 votes vote down vote up
@Test
public void testAggregatedSourceMapIsCreated() throws IOException, MojoExecutionException, MojoFailureException {
    JavaScriptCompilerMojo mojo = new JavaScriptCompilerMojo();
    mojo.googleClosureMinifierSuffix = "-min";
    mojo.basedir = new File("target/junk/root");
    mojo.buildDirectory = new File(mojo.basedir, "target");
    MavenProject project = mock(MavenProject.class);
    when(project.getArtifactId()).thenReturn("my-artifact");
    mojo.project = project;
    mojo.googleClosureCompilationLevel = CompilationLevel.ADVANCED_OPTIMIZATIONS;
    mojo.googleClosureMap = true;

    Aggregation aggregation = new Aggregation();
    aggregation.setMinification(true);

    JavaScript javascript = new JavaScript();
    javascript.setAggregations(singletonList(new Aggregation()));
    mojo.javascript = javascript;

    mojo.execute();

    File map = new File(mojo.getDefaultOutputFile(aggregation).getParentFile(), "my-artifact-min.js.map");

    assertThat(mojo.getDefaultOutputFile(aggregation)).hasContent("\n//# sourceMappingURL=my-artifact-min.js.map");
    assertThat(map).exists();
    assertThat(lineIterator(map)).contains("\"file\":\"my-artifact-min.js\",");
}