Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add custom closure compiler runner (#2935)
- Loading branch information
1 parent
2a7b33c
commit 1933961
Showing
8 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.DS_Store | ||
.g4ignore | ||
build | ||
build-system/build/classes | ||
c | ||
dist | ||
dist.3p | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 not shown.
Binary file not shown.
26 changes: 26 additions & 0 deletions
26
build-system/runner/src/org/ampproject/AmpCommandLineRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters