Skip to content

Commit

Permalink
add custom closure compiler runner (#2935)
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinmombay committed Apr 20, 2016
1 parent 2a7b33c commit 1933961
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,6 +1,7 @@
.DS_Store
.g4ignore
build
build-system/build/classes
c
dist
dist.3p
Expand Down
7 changes: 7 additions & 0 deletions build-system/runner/.classpath
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/compiler.jar" sourcepath="/Users/erwinm/dev/java/closure-compiler"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
17 changes: 17 additions & 0 deletions build-system/runner/.project
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>runner</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
75 changes: 75 additions & 0 deletions build-system/runner/build.xml
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="jar" basedir="." name="runner">
<!--
Use -Dtest.class to change what tests are run on the command-line.
i.e., -Dtest.class=CommandLineRunnerTest will run just that test class.
-->
<property name="test.class" value="*Test"/>

<!-- Use -Dtest.method in conjunction with the one-test rule. -->
<property name="test.method" value=""/>

<!--
Use -Dtest.fork to specify whether or not to fork the process.
Some machines run better with forking turned off.
-->
<property name="test.fork" value="true"/>

<!--this file was created by Eclipse Runnable JAR file Export Wizard-->
<!--ANT 1.7 is required-->
<!--define folder properties-->
<property name="dir.buildfile" value="."/>
<property name="src.dir" value="${basedir}/src"/>
<property name="gen.dir" value="${basedir}/gen"/>
<property name="test.dir" value="${basedir}/test"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="runner-jarfile" value="${build.dir}/${ant.project.name}.jar"/>

<property name="classes.dir" value="${build.dir}/classes"/>
<property name="testClasses.dir" value="${build.dir}/test"/>

<target name="jar" depends="compile">
<jar destfile="${runner-jarfile}">
<zipfileset src="${lib.dir}/jar-in-jar-loader.zip"/>
<fileset dir="${classes.dir}"/>
<fileset dir="${lib.dir}">
<include name="compiler.jar"/>
</fileset>
<manifest>
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/>
<attribute name="Rsrc-Main-Class" value="org.ampproject.AmpCommandLineRunner"/>
<attribute name="Class-Path" value="."/>
<attribute name="Rsrc-Class-Path" value="./ compiler.jar"/>
</manifest>
</jar>
</target>

<target name="compile">
<mkdir dir="${classes.dir}"/>
<copy file="${src.dir}/../../../third_party/closure-compiler/compiler.jar" todir="${lib.dir}"/>
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
excludes=".git,.DS_Store"
includeantruntime="false"
encoding="utf-8">
<classpath refid="srcclasspath.path"/>
<compilerarg value="-Xlint:unchecked"/>
</javac>
</target>

<target name="clean" description="delete generated files">
<delete dir="${build.dir}"/>
</target>

<path id="srcclasspath.path">
<pathelement location="${classes.dir}"/>
<fileset dir="${lib.dir}">
<include name="compiler.jar"/>
</fileset>
</path>

<path id="allclasspath.path">
<pathelement location="${classes.dir}"/>
</path>
</project>
Binary file added build-system/runner/build/runner.jar
Binary file not shown.
Binary file added build-system/runner/lib/jar-in-jar-loader.zip
Binary file not shown.
26 changes: 26 additions & 0 deletions build-system/runner/src/org/ampproject/AmpCommandLineRunner.java
@@ -0,0 +1,26 @@
package org.ampproject;


import com.google.javascript.jscomp.CommandLineRunner;


/**
* Adds a way to add custom options and custom compiler passes.
*/
public class AmpCommandLineRunner extends CommandLineRunner {

protected AmpCommandLineRunner(String[] args) {
super(args);
}

public static void main(String[] args) {
AmpCommandLineRunner runner = new AmpCommandLineRunner(args);

if (runner.shouldRunCompiler()) {
runner.run();
}
if (runner.hasErrors()) {
System.exit(-1);
}
}
}
4 changes: 2 additions & 2 deletions build-system/tasks/compile.js
Expand Up @@ -164,7 +164,7 @@ function compile(entryModuleFilename, outputDir,
.pipe(closureCompiler({
// Temporary shipping with our own compiler that has a single patch
// applied
compilerPath: 'third_party/closure-compiler/compiler.jar',
compilerPath: 'build-system/runner/build/runner.jar',
fileName: intermediateFilename,
continueWithWarnings: true,
tieredCompilation: true, // Magic speed up.
Expand Down Expand Up @@ -198,7 +198,7 @@ function compile(entryModuleFilename, outputDir,
.pipe(gulp.dest(outputDir))
.on('end', function() {
console./*OK*/log('Compiled', entryModuleFilename, 'to',
outputDir + outputFilename, 'via', intermediateFilename);
outputDir + '/' + outputFilename, 'via', intermediateFilename);
gulp.src(intermediateFilename + '.map')
.pipe(rename(outputFilename + '.map'))
.pipe(gulp.dest(outputDir))
Expand Down

0 comments on commit 1933961

Please sign in to comment.