diff options
-rw-r--r-- | buildScripts/compile.ant.xml | 18 | ||||
-rw-r--r-- | buildScripts/create-eclipse-project.ant.xml | 2 | ||||
-rw-r--r-- | buildScripts/setup.ant.xml | 10 | ||||
-rw-r--r-- | buildScripts/tests.ant.xml | 6 | ||||
-rw-r--r-- | src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java | 18 | ||||
-rw-r--r-- | test/core/src/lombok/AbstractRunTests.java | 4 | ||||
-rw-r--r-- | test/core/src/lombok/LombokTestSource.java | 4 | ||||
-rw-r--r-- | test/core/src/lombok/RunTestsViaDelombok.java | 2 | ||||
-rw-r--r-- | test/core/src/lombok/RunTestsViaEcj.java | 11 |
9 files changed, 49 insertions, 26 deletions
diff --git a/buildScripts/compile.ant.xml b/buildScripts/compile.ant.xml index 0bcc55bb..f0c0ef7e 100644 --- a/buildScripts/compile.ant.xml +++ b/buildScripts/compile.ant.xml @@ -30,7 +30,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and buil <target name="version" depends="ipp.setup, deps.jdk-runtime" description="Shows the version number" unless="lombok.version"> <mkdir dir="build/lombok" /> <ivy:compile destdir="build/lombok" source="1.5" target="1.5" ecj="true" nowarn="true"> - <bootclasspath path="${jdk-rt.loc}" /> + <bootclasspath path="${jdk6-rt.loc}" /> <src path="src/core" /> <include name="lombok/core/Version.java" /> </ivy:compile> @@ -73,11 +73,11 @@ This buildfile is part of projectlombok.org. It takes care of compiling and buil However, the stubs themselves also have a ton of dependencies; to avoid _that_, we have stubs for stubs, too! --> <ivy:compile destdir="build/stubsstubs" source="1.5" target="1.5" ecj="true"> - <bootclasspath path="${jdk-rt.loc}" /> + <bootclasspath path="${jdk6-rt.loc}" /> <src path="src/stubsstubs" /> </ivy:compile> <ivy:compile destdir="build/stubs" source="1.5" target="1.5" ecj="true"> - <bootclasspath path="${jdk-rt.loc}" /> + <bootclasspath path="${jdk6-rt.loc}" /> <src path="src/stubs" /> <src path="src/javac-only-stubs" /> <classpath location="build/stubsstubs" /> @@ -108,19 +108,19 @@ This buildfile is part of projectlombok.org. It takes care of compiling and buil <ivy:compile destdir="build/lombok" source="1.4" target="1.4" ecj="true"> <bootclasspath location="build/stubs" /> - <bootclasspath path="${jdk-rt.loc}" /> + <bootclasspath path="${jdk6-rt.loc}" /> <src path="build/transformedSources" /> </ivy:compile> <ivy:compile destdir="build/lombok/Class50" source="1.4" target="1.6" ecj="true"> <bootclasspath location="build/stubs" /> - <bootclasspath path="${jdk-rt.loc}" /> + <bootclasspath path="${jdk6-rt.loc}" /> <src path="build/transformedSources" /> </ivy:compile> <ivy:compile destdir="build/lombok" source="1.5" target="1.5" ecj="true"> <bootclasspath location="build/stubs" /> - <bootclasspath path="${jdk-rt.loc}" /> + <bootclasspath path="${jdk6-rt.loc}" /> <src path="src/utils" /> <exclude name="lombok/javac/**" /> <classpath path="build/lombok" /> @@ -129,7 +129,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and buil </ivy:compile> <ivy:compile destdir="build/lombok" source="1.6" target="1.6" ecj="true"> <bootclasspath location="build/stubs" /> - <bootclasspath path="${jdk-rt.loc}" /> + <bootclasspath path="${jdk6-rt.loc}" /> <src path="src/utils" /> <include name="lombok/javac/**" /> <classpath location="build/lombok" /> @@ -141,7 +141,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and buil use API that didn't exist in those versions yet. --> <ivy:compile destdir="build/lombok" source="1.6" target="1.6" ecj="true" nowarn="true"> <bootclasspath location="build/stubs" /> - <bootclasspath path="${jdk-rt.loc}" /> + <bootclasspath path="${jdk6-rt.loc}" /> <src path="src/launch" /> <src path="src/core" /> <src path="src/installer" /> @@ -157,7 +157,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and buil <!-- This is really part of the eclipse agent, but references lombok, so that had to be compiled first --> <ivy:compile destdir="build/lombok/Class50" source="1.5" target="1.6" ecj="true"> <bootclasspath location="build/stubs" /> - <bootclasspath path="${jdk-rt.loc}" /> + <bootclasspath path="${jdk6-rt.loc}" /> <src path="src/eclipseAgent" /> <include name="lombok/launch/PatchFixesHider.java" /> <classpath location="build/lombok" /> diff --git a/buildScripts/create-eclipse-project.ant.xml b/buildScripts/create-eclipse-project.ant.xml index 386ed3de..89e2f91f 100644 --- a/buildScripts/create-eclipse-project.ant.xml +++ b/buildScripts/create-eclipse-project.ant.xml @@ -69,6 +69,7 @@ This buildfile is part of projectlombok.org. It creates the infrastructure neede <arg value="name=Lombok-test Base" /> <arg value="testType=lombok.TestBase" /> <arg value="jvmTarget=1.8" /> + <arg value="bootpath=${jdk8-rt.loc}" /> <arg value="conf.test=${cp.test}" /> <arg value="conf.stripe=${cp.stripe}" /> <arg value="favorite" /> @@ -82,6 +83,7 @@ This buildfile is part of projectlombok.org. It creates the infrastructure neede <arg value="name=Lombok-test Eclipse-202006" /> <arg value="testType=lombok.TestEclipse" /> <arg value="jvmTarget=1.8" /> + <arg value="bootpath=${jdk8-rt.loc}" /> <arg value="conf.test=${cp.test}" /> <arg value="conf.stripe=${cp.stripe}" /> <arg value="conf.eclipse-oxygen=${cp.eclipse-202006}" /> diff --git a/buildScripts/setup.ant.xml b/buildScripts/setup.ant.xml index d6713222..6ab23897 100644 --- a/buildScripts/setup.ant.xml +++ b/buildScripts/setup.ant.xml @@ -29,9 +29,9 @@ This buildfile is part of projectlombok.org. It sets up the build itself. <property environment="env" /> <available file="lib/ivyplusplus.jar" property="ivyplusplus.available" /> - <property name="jdk-rt.loc" location="lib/openjdk6_rt.jar" /> + <property name="jdk6-rt.loc" location="lib/openjdk6_rt.jar" /> <property name="jdk8-rt.loc" location="lib/openjdk8_rt.jar" /> - <available file="${jdk-rt.loc}" property="jdk-rt.available" /> + <available file="${jdk6-rt.loc}" property="jdk6-rt.available" /> <available file="${jdk8-rt.loc}" property="jdk8-rt.available" /> <property name="ssh.configuration.file" location="ssh.configuration" /> @@ -121,10 +121,10 @@ This buildfile is part of projectlombok.org. It sets up the build itself. <property name="ivy.config" value="true" /> </target> - <target name="deps.jdk6-runtime" unless="jdk-rt.available"> + <target name="deps.jdk6-runtime" unless="jdk6-rt.available"> <echo>To ensure stable builds and avoid accessing API that was not available in JDK6, most of lombok is set up to build against OpenJDK6's runtime, which will now be downloaded...</echo> <mkdir dir="lib" /> - <get src="https://projectlombok.org/ivyrepo/langtools/rt-openjdk6.jar" dest="${jdk-rt.loc}" verbose="true" usetimestamp="true" /> + <get src="https://projectlombok.org/ivyrepo/langtools/rt-openjdk6.jar" dest="${jdk6-rt.loc}" verbose="true" usetimestamp="true" /> </target> <target name="deps.jdk8-runtime" unless="jdk8-rt.available"> @@ -133,7 +133,7 @@ This buildfile is part of projectlombok.org. It sets up the build itself. <get src="https://projectlombok.org/ivyrepo/langtools/rt-openjdk8.jar" dest="${jdk8-rt.loc}" verbose="true" usetimestamp="true" /> </target> - <target name="deps.jdk-runtime" depends="deps.jdk6-runtime" /> + <target name="deps.jdk-runtime" depends="deps.jdk6-runtime, deps.jdk8-runtime" /> <target name="deps.custom" depends="ivy.config" description="Download the dependencies that comprise a configuration (from ivy.xml)"> <fail unless="deps.conf">Supply ant with -Ddeps.conf=confname to pick the configuration you want to fetch</fail> diff --git a/buildScripts/tests.ant.xml b/buildScripts/tests.ant.xml index 67edf28a..d8559c5c 100644 --- a/buildScripts/tests.ant.xml +++ b/buildScripts/tests.ant.xml @@ -30,7 +30,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <src path="test/stubs" /> </ivy:compile> <ivy:compile destdir="build/tests" source="1.5" target="1.5" ecj="true" nowarn="true"> - <bootclasspath path="${jdk-rt.loc}" /> + <bootclasspath path="${jdk6-rt.loc}" /> <classpath refid="cp.test" /> <classpath refid="cp.eclipse-oxygen" /> <classpath location="build/lombok" /> @@ -77,9 +77,9 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <target name="test.javac6" depends="test.compile" description="runs the tests on your default VM, using javac6 as underlying compiler"> <echo>Running TestJavac on JVM${ant.java.version}, with lowest supported javac: 1.6.</echo> <junit haltonfailure="yes" fork="true" forkmode="once"> - <jvmarg value="-Xbootclasspath/a:${jdk-rt.loc}" /> + <jvmarg value="-Xbootclasspath/a:${jdk6-rt.loc}" /> <jvmarg line="${test.limitmodules}" /> - <jvmarg value="-Ddelombok.bootclasspath=${jdk-rt.loc}" /> + <jvmarg value="-Ddelombok.bootclasspath=${jdk6-rt.loc}" /> <formatter type="plain" usefile="false" unless="tests.quiet" /> <classpath refid="cp.test" /> <classpath refid="cp.stripe" /> diff --git a/src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java b/src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java index d3b314cb..d00524f7 100644 --- a/src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java +++ b/src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java @@ -93,6 +93,8 @@ public class CreateEclipseDebugTarget { throw new InvalidCommandLineException("Cannot obtain canonical path to parent directory", e); } + String bootpath = getBootPath(); + launchContent.append("\t\t<listEntry value=\"<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/bin" path="3" type="2"/> \"/>\n"); for (Map.Entry<String, String> entry : args.entrySet()) { if (!entry.getKey().startsWith("conf.")) continue; @@ -111,7 +113,7 @@ public class CreateEclipseDebugTarget { } } } - launchContent.append("\t\t<listEntry value=\"<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/lib/openjdk6_rt.jar" path="5" type="2"/> \"/>\n"); + if (bootpath != null) launchContent.append("\t\t<listEntry value=\"<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/" + bootpath + "" path="5" type="2"/> \"/>\n"); launchContent.append("\t</listAttribute>\n"); } @@ -120,6 +122,7 @@ public class CreateEclipseDebugTarget { launchContent.append("\t<booleanAttribute key=\"org.eclipse.jdt.launching.DEFAULT_CLASSPATH\" value=\"false\"/>\n"); String jvmTarget = getArgString("jvmTarget"); + String bootpath = getBootPath(); launchContent.append("\t<stringAttribute key=\"org.eclipse.jdt.launching.JRE_CONTAINER\" value=\"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-").append(jvmTarget).append("\"/>\n"); launchContent.append("\t<stringAttribute key=\"org.eclipse.jdt.launching.MAIN_TYPE\" value=\"").append(type).append("\"/>\n"); launchContent.append("\t<listAttribute key=\"org.eclipse.jdt.launching.MODULEPATH\"/>\n"); @@ -129,10 +132,21 @@ public class CreateEclipseDebugTarget { if (!entry.getKey().startsWith("conf.")) continue; launchContent.append(File.pathSeparator).append(entry.getValue()); } - launchContent.append(" -Ddelombok.bootclasspath=lib/openjdk6_rt.jar\"/>\n"); + if (bootpath != null) launchContent.append(" -Ddelombok.bootclasspath=" + bootpath + "\"/>\n"); launchContent.append("</launchConfiguration>\n"); } + private String getBootPath() { + String bp = args.get("bootpath"); + if (bp == null) return null; + File f = new File(bp); + if (!f.isAbsolute()) return bp; + String r = new File(".").getAbsolutePath(); + if (r.endsWith(".")) r = r.substring(0, r.length() - 1); + if (bp.startsWith(r)) return bp.substring(r.length()); + throw new IllegalStateException("Cannot reconstruct relative path; base: " + r + " is not a parent of " + bp); + } + private String getArgString(String key) throws InvalidCommandLineException { String v = args.get(key); if (v == null) throw new InvalidCommandLineException("mandatory argument '" + key + "' missing"); diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index d223ae03..6d2b6312 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -91,7 +91,7 @@ public abstract class AbstractRunTests { } }); - boolean changed = transformCode(messages, writer, file, sourceDirectives_.getSpecifiedEncoding(), sourceDirectives_.getFormatPreferences()); + boolean changed = transformCode(messages, writer, file, sourceDirectives_.getSpecifiedEncoding(), sourceDirectives_.getFormatPreferences(), sourceDirectives_.minVersion()); boolean forceUnchanged = sourceDirectives_.forceUnchanged() || sourceDirectives_.isSkipCompareContent(); if (params.expectChanges() && !forceUnchanged && !changed) messages.add(new CompilerMessage(-1, -1, true, "not flagged modified")); if (!params.expectChanges() && changed) messages.add(new CompilerMessage(-1, -1, true, "unexpected modification")); @@ -101,7 +101,7 @@ public abstract class AbstractRunTests { }; } - protected abstract boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences) throws Throwable; + protected abstract boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences, int minVersion) throws Throwable; protected String readFile(File file) throws IOException { BufferedReader reader; diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java index b04f0ba0..57a32333 100644 --- a/test/core/src/lombok/LombokTestSource.java +++ b/test/core/src/lombok/LombokTestSource.java @@ -358,4 +358,8 @@ public class LombokTestSource { if (specifiedEncoding == null || specifiedEncoding.equalsIgnoreCase(encoding)) return source; return read0(sourceFolder, messagesFolder, fileName, specifiedEncoding); } + + public int minVersion() { + return Math.max(6, versionLowerLimit); + } } diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java index b766e7a4..4260f2da 100644 --- a/test/core/src/lombok/RunTestsViaDelombok.java +++ b/test/core/src/lombok/RunTestsViaDelombok.java @@ -41,7 +41,7 @@ public class RunTestsViaDelombok extends AbstractRunTests { private static AtomicBoolean compilerVersionReported = new AtomicBoolean(); @Override - public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, final File file, String encoding, Map<String, String> formatPreferences) throws Throwable { + public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, final File file, String encoding, Map<String, String> formatPreferences, int version) throws Throwable { if (!compilerVersionReported.getAndSet(true)) System.out.println("Javac version: " + Javac.getJavaCompilerVersion()); delombok.setVerbose(true); ChangedChecker cc = new ChangedChecker(); diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java index 77d1b75e..ab28cb0c 100644 --- a/test/core/src/lombok/RunTestsViaEcj.java +++ b/test/core/src/lombok/RunTestsViaEcj.java @@ -93,7 +93,7 @@ public class RunTestsViaEcj extends AbstractRunTests { } @Override - public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences) throws Throwable { + public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences, int minVersion) throws Throwable { final AtomicReference<CompilationResult> compilationResult_ = new AtomicReference<CompilationResult>(); final AtomicReference<CompilationUnitDeclaration> compilationUnit_ = new AtomicReference<CompilationUnitDeclaration>(); ICompilerRequestor bitbucketRequestor = new ICompilerRequestor() { @@ -105,7 +105,7 @@ public class RunTestsViaEcj extends AbstractRunTests { String source = readFile(file); final CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), encoding == null ? "UTF-8" : encoding); - Compiler ecjCompiler = new Compiler(createFileSystem(file), ecjErrorHandlingPolicy(), ecjCompilerOptions(), bitbucketRequestor, new DefaultProblemFactory(Locale.ENGLISH)) { + Compiler ecjCompiler = new Compiler(createFileSystem(file, minVersion), ecjErrorHandlingPolicy(), ecjCompilerOptions(), bitbucketRequestor, new DefaultProblemFactory(Locale.ENGLISH)) { @Override protected synchronized void addCompilationUnit(ICompilationUnit inUnit, CompilationUnitDeclaration parsedUnit) { if (inUnit == sourceUnit) compilationUnit_.set(parsedUnit); super.addCompilationUnit(inUnit, parsedUnit); @@ -129,7 +129,9 @@ public class RunTestsViaEcj extends AbstractRunTests { return true; } - private FileSystem createFileSystem(File file) { + private static final String bootRuntimePath = System.getProperty("delombok.bootclasspath"); + + private FileSystem createFileSystem(File file, int minVersion) { List<String> classpath = new ArrayList<String>(); for (Iterator<String> i = classpath.iterator(); i.hasNext();) { if (FileSystem.getClasspath(i.next(), "UTF-8", null) == null) { @@ -138,7 +140,8 @@ public class RunTestsViaEcj extends AbstractRunTests { } if (new File("bin").exists()) classpath.add("bin"); classpath.add("dist/lombok.jar"); - classpath.add("lib/openjdk6_rt.jar"); + if (bootRuntimePath == null || bootRuntimePath.isEmpty()) throw new IllegalStateException("System property delombok.bootclasspath is not set; set it to the rt of java6 or java8"); + classpath.add(bootRuntimePath); for (File f : new File("lib/test").listFiles()) { String fn = f.getName(); if (fn.length() < 4) continue; |