Skip to content

Commit

Permalink
Fix gradle func tests running in idea (#74811)
Browse files Browse the repository at this point in the history
* Fix gradle func tests running in idea

* Tweak wrapper task
  • Loading branch information
breskeby authored Jul 1, 2021
1 parent 59d4508 commit 1ea7e50
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
11 changes: 5 additions & 6 deletions build-conventions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {
compileOnly "com.puppycrawl.tools:checkstyle:8.42"
}

project.getPlugins().withType(JavaBasePlugin.class, javaBasePlugin -> {
project.getPlugins().withType(JavaBasePlugin.class) {
java.getModularity().getInferModulePath().set(false);
eclipse.getClasspath().getFile().whenMerged { classpath ->
/*
Expand All @@ -69,9 +69,8 @@ project.getPlugins().withType(JavaBasePlugin.class, javaBasePlugin -> {
* in the usual build folder because eclipse becomes *very* sad
* if we delete it. Which `gradlew clean` does all the time.
*/
int i = 0;
classpath.getEntries().stream().filter(e -> e instanceof SourceFolder).forEachOrdered(s ->
s.setOutput("out/eclipse"+i++)
)
classpath.getEntries().findAll{ s -> s instanceof SourceFolder }.eachWithIndex { s, i ->
s.setOutput("out/eclipse" + i)
}
}
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public void execute(Delete delete) {
}

private File root(Project project) {
return project.getGradle().getParent() == null ?
project.getRootDir() :
root(project.getGradle().getParent().getRootProject());
return project.getRootProject().getName().equals("elasticsearch") ?
project.getRootProject().getRootDir() :
project.getRootDir().getParentFile();
}
}
6 changes: 6 additions & 0 deletions build-tools-internal/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=a9e356a21595348b6f04b024ed0b08ac8aea6b2ac37e6c0ef58e51549cd7b9cb
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import static org.elasticsearch.gradle.util.GradleUtils.maybeConfigure
import org.gradle.plugins.ide.eclipse.model.ProjectDependency
import org.elasticsearch.gradle.internal.InternalPluginBuildPlugin
import org.elasticsearch.gradle.internal.ResolveAllDependencies
import java.nio.file.Files
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;

plugins {
id 'lifecycle-base'
Expand Down Expand Up @@ -380,6 +382,9 @@ tasks.named("wrapper").configure {
final String sha256Sum = new String(sha256Uri.toURL().bytes)
wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256Sum}\n"
println "Added checksum to wrapper properties"
// copy wrapper properties file to build-tools-internal to allow seamless idea integration
def file = new File("build-tools-internal/gradle/wrapper/gradle-wrapper.properties")
Files.copy(wrapper.getPropertiesFile().toPath(), file.toPath(), REPLACE_EXISTING)
// Update build-tools to reflect the Gradle upgrade
// TODO: we can remove this once we have tests to make sure older versions work.
project.file('build-tools-internal/src/main/resources/minimumGradleVersion').text = gradleVersion
Expand Down

0 comments on commit 1ea7e50

Please sign in to comment.