diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | build.xml | 51 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/Delombok.java | 16 | ||||
-rw-r--r-- | test/core/src/lombok/RunTestsViaDelombok.java | 2 |
4 files changed, 63 insertions, 9 deletions
@@ -1,3 +1,4 @@ +/testenvironment.properties /bin /build /dist @@ -16,4 +17,4 @@ /lombok.iml /.idea *.markdown.html -/junit*.properties
\ No newline at end of file +/junit*.properties @@ -327,13 +327,60 @@ the common tasks and can be called on to run the main aspects of all the sub-scr </java> </target> - <target name="test" depends="-test-compile, dist, test-ecj" unless="tests.skip" description="Runs the tests."> + <target name="-loadTestEnvironmentProperties"> + <property file="testenvironment.properties" /> + </target> + + <target name="setupJava6TestEnvironment" description="Sets up the test so that 'ant test' will test against OpenJDK6."> + <mkdir dir="lib/openJDK6Environment" /> + <get src="http://projectlombok.org/ivyrepo/langtools/javac-1.6.0.18.jar" dest="lib/openJDK6Environment/javac6.jar" verbose="true" usetimestamp="true" /> + <get src="http://projectlombok.org/ivyrepo/langtools/rt-openjdk6.jar" dest="lib/openJDK6Environment/rt-openjdk6.jar" verbose="true" usetimestamp="true" /> + <propertyfile file="testenvironment.properties"> + <entry key="test.location.javac" value="lib/openJDK6Environment/javac6.jar" /> + <entry key="test.location.bootclasspath" value="lib/openJDK6Environment/rt-openjdk6.jar" /> + </propertyfile> + <echo>Tests will now run against OpenJDK6</echo> + </target> + + <target name="setupJava7TestEnvironment" description="Sets up the test so that 'ant test' will test against OpenJDK7."> + <mkdir dir="lib/openJDK7Environment" /> + <get src="http://projectlombok.org/ivyrepo/langtools/javac-1.7.0.jar" dest="lib/openJDK7Environment/javac7.jar" verbose="true" usetimestamp="true" /> + <get src="http://projectlombok.org/ivyrepo/langtools/rt-openjdk7.jar" dest="lib/openJDK7Environment/rt-openjdk7.jar" verbose="true" usetimestamp="true" /> + <propertyfile file="testenvironment.properties"> + <entry key="test.location.javac" value="lib/openJDK7Environment/javac7.jar" /> + <entry key="test.location.bootclasspath" value="lib/openJDK7Environment/rt-openjdk7.jar" /> + </propertyfile> + <echo>Tests will now run against OpenJDK7</echo> + </target> + + <target name="-failIfNoTestEnvironmentProperties" unless="test.location.javac"> + <fail unless="test.location.javac">ERROR: No test environment set up. + +You need to set up a test environment, which consists of a version of javac, and a JRE runtime classpath ('rt.jar'). +Eventually, this environment concept will be extended to also includes an ecj and/or eclipse to test against. + +You can let this ant script set them up for you: + +* ant setupJava6TestEnvironment +* ant setupJava7TestEnvironment + +These will set up test environments based on OpenJDK6 and OpenJDK7 and some recent version of eclipse, and download all required files automatically. This will be a relatively large download. You can switch by running this command again; the downloads are cached so switching is fast. + +You can also create your own by writing a 'testenvironment.properties' file. The relevant properties are: + +* test.location.javac = /path/to/javac6.jar +* test.location.bootclasspath = /path/to/rt.jar +</fail> + </target> + + <target name="test" depends="-loadTestEnvironmentProperties, -failIfNoTestEnvironmentProperties, -test-compile, dist, test-ecj" unless="tests.skip" description="Runs the tests."> <junit haltonfailure="yes" fork="true"> <jvmarg value="-javaagent:dist/lombok.jar" /> + <jvmarg value="-Ddelombok.bootclasspath=${test.location.bootclasspath}" /> <formatter type="plain" usefile="false" unless="tests.quiet" /> <classpath refid="test.path" /> <classpath refid="eclipseBuild.path" /> - <classpath path="lib/javac6/javac6.jar" /> + <classpath path="${test.location.javac}" /> <classpath path="build/lombok" /> <classpath path="build/tests" /> <batchtest> diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index 3f521274..f67e3724 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -68,15 +68,11 @@ public class Delombok { this.presetWriter = writer; } - public Delombok() { -// context.put(DeleteLombokAnnotations.class, new DeleteLombokAnnotations(true)); - } - private PrintStream feedback = System.err; private boolean verbose; private boolean noCopy; private boolean force = false; - private String classpath, sourcepath; + private String classpath, sourcepath, bootclasspath; private LinkedHashMap<File, File> fileToBase = new LinkedHashMap<File, File>(); private List<File> filesToParse = new ArrayList<File>(); @@ -115,6 +111,9 @@ public class Delombok { @Description("Sourcepath (analogous to javac -sourcepath option)") private String sourcepath; + @Description("override Bootclasspath (analogous to javac -bootclasspath option)") + private String bootclasspath; + @Description("Files to delombok. Provide either a file, or a directory. If you use a directory, all files in it (recursive) are delombok-ed") @Sequential private List<String> input = new ArrayList<String>(); @@ -173,6 +172,7 @@ public class Delombok { if (args.classpath != null) delombok.setClasspath(args.classpath); if (args.sourcepath != null) delombok.setSourcepath(args.sourcepath); + if (args.bootclasspath != null) delombok.setBootclasspath(args.bootclasspath); try { for (String in : args.input) { @@ -230,6 +230,10 @@ public class Delombok { this.sourcepath = sourcepath; } + public void setBootclasspath(String bootclasspath) { + this.bootclasspath = bootclasspath; + } + public void setVerbose(boolean verbose) { this.verbose = verbose; } @@ -355,6 +359,7 @@ public class Delombok { options.put(OptionName.ENCODING, charset.name()); if (classpath != null) options.put(OptionName.CLASSPATH, classpath); if (sourcepath != null) options.put(OptionName.SOURCEPATH, sourcepath); + if (bootclasspath != null) options.put(OptionName.BOOTCLASSPATH, bootclasspath); options.put("compilePolicy", "attr"); CommentCatcher catcher = CommentCatcher.create(context); @@ -363,7 +368,6 @@ public class Delombok { List<JCCompilationUnit> roots = new ArrayList<JCCompilationUnit>(); Map<JCCompilationUnit, File> baseMap = new IdentityHashMap<JCCompilationUnit, File>(); - compiler.initProcessAnnotations(Collections.singleton(new lombok.javac.apt.Processor())); for (File fileToParse : filesToParse) { diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java index 52653e2e..e58cffc0 100644 --- a/test/core/src/lombok/RunTestsViaDelombok.java +++ b/test/core/src/lombok/RunTestsViaDelombok.java @@ -55,6 +55,8 @@ public class RunTestsViaDelombok extends AbstractRunTests { delombok.addFile(file.getAbsoluteFile().getParentFile(), file.getName()); delombok.setSourcepath(file.getAbsoluteFile().getParent()); + String bcp = System.getProperty("delombok.bootclasspath"); + if (bcp != null) delombok.setBootclasspath(bcp); delombok.setWriter(result); Locale originalLocale = Locale.getDefault(); try { |