[gradle] 01/04: Backported a fix to support the javac --module-source-path option
Emmanuel Bourg
ebourg-guest at moszumanska.debian.org
Wed Apr 4 15:33:03 UTC 2018
This is an automated email from the git hooks/post-receive script.
ebourg-guest pushed a commit to branch master
in repository gradle.
commit b06af42d2f19351e370ac88419a98a1fd091846b
Author: Emmanuel Bourg <ebourg at apache.org>
Date: Wed Apr 4 16:43:02 2018 +0200
Backported a fix to support the javac --module-source-path option
---
debian/changelog | 7 ++
...w-both-module-source-path-and-source-path.patch | 114 +++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 122 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 9af791e..7bbf1fc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+gradle (3.4.1-5) UNRELEASED; urgency=medium
+
+ * Team upload.
+ * Backported a fix to support the javac --module-source-path option
+
+ -- Emmanuel Bourg <ebourg at apache.org> Wed, 04 Apr 2018 13:34:54 +0200
+
gradle (3.4.1-4) unstable; urgency=medium
* Team upload.
diff --git a/debian/patches/disallow-both-module-source-path-and-source-path.patch b/debian/patches/disallow-both-module-source-path-and-source-path.patch
new file mode 100644
index 0000000..e9e4c0a
--- /dev/null
+++ b/debian/patches/disallow-both-module-source-path-and-source-path.patch
@@ -0,0 +1,114 @@
+From e9f4cb3be4b0a16506ad54b44485b7f0862f6c59 Mon Sep 17 00:00:00 2001
+From: Pepper Lebeck-Jobe <pepper at gradle.com>
+Date: Thu, 20 Jul 2017 14:58:11 +0200
+Subject: [PATCH] Disallow both --module-source-path and -sourcepath (#2542)
+
+Java 9 introduces a `--module-source-path` option which is mutually
+exclusive with `-sourcepath` or `--source-path`. If they are both
+provided, the sourcepath should be stripped and the
+`--module-source-path` should remain.
+
+If both have been specified explicitly by the user either as a
+`optiions.compilerArgs` argument or, in the case of `sourcepath` as
+the `options.sourcepath` property, then a warning should also be
+emitted to let the user know that they did something wrong.
+
+Fixes #2537
+---
+ .../compile/JavaCompilerArgumentsBuilder.java | 20 +++-
+ .../JavaCompilerArgumentsBuilderTest.groovy | 10 ++
+ 3 files changed, 125 insertions(+), 12 deletions(-)
+
+--- a/subprojects/language-java/src/main/java/org/gradle/api/internal/tasks/compile/JavaCompilerArgumentsBuilder.java
++++ b/subprojects/language-java/src/main/java/org/gradle/api/internal/tasks/compile/JavaCompilerArgumentsBuilder.java
+@@ -19,14 +19,19 @@
+ import com.google.common.base.Joiner;
+ import org.gradle.api.JavaVersion;
+ import org.gradle.api.file.FileCollection;
++import org.gradle.api.logging.Logger;
++import org.gradle.api.logging.Logging;
+ import org.gradle.api.tasks.compile.CompileOptions;
+ import org.gradle.api.tasks.compile.ForkOptions;
++import org.gradle.util.DeprecationLogger;
+
+ import java.io.File;
+ import java.util.ArrayList;
++import java.util.Iterator;
+ import java.util.List;
+
+ public class JavaCompilerArgumentsBuilder {
++ public static final Logger LOGGER = Logging.getLogger(JavaCompilerArgumentsBuilder.class);
+ public static final String USE_UNSHARED_COMPILER_TABLE_OPTION = "-XDuseUnsharedTable=true";
+ public static final String EMPTY_SOURCE_PATH_REF_DIR = "emptySourcePathRef";
+
+@@ -155,9 +160,10 @@
+ }
+
+ FileCollection sourcepath = compileOptions.getSourcepath();
+- if (!noEmptySourcePath || sourcepath != null && sourcepath.isEmpty()) {
++ String userProvidedSourcepath = extractSourcepathFrom(compilerArgs, false);
++ if (!noEmptySourcePath || sourcepath != null && !sourcepath.isEmpty() || !userProvidedSourcepath.isEmpty()) {
+ args.add("-sourcepath");
+- args.add(sourcepath == null ? "" : sourcepath.getAsPath());
++ args.add(sourcepath == null ? userProvidedSourcepath : Joiner.on(File.pathSeparator).skipNulls().join(sourcepath.getAsPath(), userProvidedSourcepath.isEmpty() ? null : userProvidedSourcepath));
+ }
+
+ if (spec.getSourceCompatibility() == null || JavaVersion.toVersion(spec.getSourceCompatibility()).compareTo(JavaVersion.VERSION_1_6) >= 0) {
+@@ -188,10 +194,38 @@
+
+ List<String> compilerArgs = spec.getCompileOptions().getCompilerArgs();
+ if (compilerArgs != null) {
++ if (compilerArgs.contains("--module-source-path")) {
++ if (!extractSourcepathFrom(args, true).isEmpty()) {
++ LOGGER.warn("You specified both --module-source-path and a sourcepath. These options are mutually exclusive. Removing sourcepath.");
++ }
++ }
+ args.addAll(compilerArgs);
+ }
+ }
+
++ private String extractSourcepathFrom(List<String> compilerArgs, boolean silently) {
++ Iterator<String> argIterator = compilerArgs.iterator();
++ String userProvidedSourcepath = "";
++ while (argIterator.hasNext()) {
++ String current = argIterator.next();
++ if (current.equals("-sourcepath") || current.equals("--source-path")) {
++ if (!silently) {
++ DeprecationLogger.nagUserOfDeprecated(
++ "Specifying the source path in the CompilerOptions compilerArgs property",
++ "Instead, use the CompilerOptions sourcepath property directly");
++ }
++ argIterator.remove();
++ if (argIterator.hasNext()) {
++ // Only conditional in case the user didn't supply an argument to the -sourcepath option.
++ // Protecting the call to "next()" inside the conditional protects against a NoSuchElementException
++ userProvidedSourcepath = argIterator.next();
++ argIterator.remove();
++ }
++ }
++ }
++ return userProvidedSourcepath;
++ }
++
+ private boolean releaseOptionIsSet(List<String> compilerArgs) {
+ return compilerArgs != null && compilerArgs.contains("-release");
+ }
+--- a/subprojects/language-java/src/test/groovy/org/gradle/api/internal/tasks/compile/JavaCompilerArgumentsBuilderTest.groovy
++++ b/subprojects/language-java/src/test/groovy/org/gradle/api/internal/tasks/compile/JavaCompilerArgumentsBuilderTest.groovy
+@@ -321,6 +321,16 @@
+ builder.build() == ["-g", "-sourcepath", fc.asPath, "-proc:none", USE_UNSHARED_COMPILER_TABLE_OPTION, "-classpath", ""]
+ }
+
++ def "removes sourcepath when module-source-path is provided"() {
++ given:
++ spec.compileOptions.compilerArgs = ['--module-source-path', '/src/other']
++ def expected = ["-g", "-proc:none", USE_UNSHARED_COMPILER_TABLE_OPTION, "-classpath", "", "--module-source-path", "/src/other"]
++
++ expect:
++ builder.build() == expected
++ builder.noEmptySourcePath().build() == expected
++ }
++
+ String defaultEmptySourcePathRefFolder() {
+ new File(spec.tempDir, JavaCompilerArgumentsBuilder.EMPTY_SOURCE_PATH_REF_DIR).absolutePath
+ }
diff --git a/debian/patches/series b/debian/patches/series
index e93162e..cc47f22 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -27,3 +27,4 @@ cast-estimated-runtime-to-long.patch
support-running-gradle-on-jdk-10-500485df3a18.patch
add-test-case-for-10-internal_c1fe5e40a76b.patch
support-zulu9-version-number_d9c35cf9d74c.patch
+disallow-both-module-source-path-and-source-path.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/gradle.git
More information about the pkg-java-commits
mailing list