From fd7d1f2ccb145c10498a4d18cb8085f0ac670a6c Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Tue, 10 Jul 2018 13:21:48 +0300 Subject: [PATCH 1/4] Fix CP for namingConventions when gradle home has spaces Closes #31736. Probably not Windows specific, just not common to have spaces on Linux. --- .../precommit/NamingConventionsTask.java | 31 +++++++++++++------ .../gradle/test/ClusterFormationTasks.groovy | 2 ++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/NamingConventionsTask.java b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/NamingConventionsTask.java index 7b63899de31ee..353de924222ae 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/NamingConventionsTask.java +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/NamingConventionsTask.java @@ -17,6 +17,8 @@ import java.io.File; import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; import java.util.Objects; /** @@ -30,16 +32,25 @@ public NamingConventionsTask() { final Project project = getProject(); SourceSetContainer sourceSets = getJavaSourceSets(); - final FileCollection classpath = project.files( - // This works because the class only depends on one class from junit that will be available from the - // tests compile classpath. It's the most straight forward way of telling Java where to find the main - // class. - NamingConventionsCheck.class.getProtectionDomain().getCodeSource().getLocation().getPath(), - // the tests to be loaded - checkForTestsInMain ? sourceSets.getByName("main").getRuntimeClasspath() : project.files(), - sourceSets.getByName("test").getCompileClasspath(), - sourceSets.getByName("test").getOutput() - ); + final FileCollection classpath; + try { + URL location = NamingConventionsCheck.class.getProtectionDomain().getCodeSource().getLocation(); + if (location.getProtocol().equals("file") == false) { + throw new GradleException("Unexpected location for NamingConventionCheck class: "+ location); + } + classpath = project.files( + // This works because the class only depends on one class from junit that will be available from the + // tests compile classpath. It's the most straight forward way of telling Java where to find the main + // class. + location.toURI().getPath(), + // the tests to be loaded + checkForTestsInMain ? sourceSets.getByName("main").getRuntimeClasspath() : project.files(), + sourceSets.getByName("test").getCompileClasspath(), + sourceSets.getByName("test").getOutput() + ); + } catch (URISyntaxException e) { + throw new GradleException("Failed to find NamingConventionsCheck class", e); + } dependsOn(project.getTasks().matching(it -> "testCompileClasspath".equals(it.getName()))); getInputs().files(classpath); diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index be0fb3a07c699..1ef39ac69a793 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -650,7 +650,9 @@ class ClusterFormationTasks { start.doFirst { project.logger.info("Starting node in ${node.clusterName} distribution: ${node.config.distribution}") } + start.ext.node = node return start + } static Task configureWaitTask(String name, Project project, List nodes, List startTasks, int waitSeconds) { From f10554836728c1c897df41d508ca148ffecd57e7 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Mon, 16 Jul 2018 09:34:12 +0300 Subject: [PATCH 2/4] Remove accidental change --- .../org/elasticsearch/gradle/test/ClusterFormationTasks.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 1ef39ac69a793..3e53e1e028dcc 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -650,7 +650,6 @@ class ClusterFormationTasks { start.doFirst { project.logger.info("Starting node in ${node.clusterName} distribution: ${node.config.distribution}") } - start.ext.node = node return start } From ade40fa41443b74625fcad95065439388860c43d Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Mon, 16 Jul 2018 09:52:30 +0300 Subject: [PATCH 3/4] PR review --- .../gradle/precommit/NamingConventionsTask.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/NamingConventionsTask.java b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/NamingConventionsTask.java index 353de924222ae..df8b08dd7c691 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/NamingConventionsTask.java +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/NamingConventionsTask.java @@ -49,7 +49,7 @@ public NamingConventionsTask() { sourceSets.getByName("test").getOutput() ); } catch (URISyntaxException e) { - throw new GradleException("Failed to find NamingConventionsCheck class", e); + throw new AssertionError(e); } dependsOn(project.getTasks().matching(it -> "testCompileClasspath".equals(it.getName()))); getInputs().files(classpath); @@ -124,10 +124,6 @@ public void setSuccessMarker(File successMarker) { this.successMarker = successMarker; } - public boolean getSkipIntegTestInDisguise() { - return skipIntegTestInDisguise; - } - public boolean isSkipIntegTestInDisguise() { return skipIntegTestInDisguise; } From f35c3351eafae5d4c4a2a0f5e3b664c6bb5182ee Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Mon, 16 Jul 2018 09:54:29 +0300 Subject: [PATCH 4/4] Remove unintentional change --- .../org/elasticsearch/gradle/test/ClusterFormationTasks.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 3e53e1e028dcc..be0fb3a07c699 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -651,7 +651,6 @@ class ClusterFormationTasks { project.logger.info("Starting node in ${node.clusterName} distribution: ${node.config.distribution}") } return start - } static Task configureWaitTask(String name, Project project, List nodes, List startTasks, int waitSeconds) {