-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build plugin with platform specific JDK #69
Changes from 3 commits
9bd4224
dfc4722
ff32bfa
0719536
a4904a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -24,7 +24,9 @@ | |||||||
import org.gradle.api.plugins.scala.ScalaPlugin; | ||||||||
import org.gradle.api.tasks.SourceSet; | ||||||||
import org.gradle.api.tasks.TaskProvider; | ||||||||
import org.gradle.api.tasks.compile.JavaCompile; | ||||||||
import org.gradle.api.tasks.testing.Test; | ||||||||
import org.gradle.jvm.toolchain.JavaToolchainService; | ||||||||
import org.gradle.language.base.plugins.LifecycleBasePlugin; | ||||||||
import org.gradle.testing.jacoco.plugins.JacocoPlugin; | ||||||||
import org.gradle.testing.jacoco.plugins.JacocoTaskExtension; | ||||||||
|
@@ -64,6 +66,7 @@ public void apply(Project project) { | |||||||
Defaults.DEFAULT_PLATFORMS.forEach( | ||||||||
platform -> configurePlatform(project, platform, mainSourceSet, testSourceSet, extension.outputDirFile)); | ||||||||
}); | ||||||||
|
||||||||
// Disable Jacoco for platform test tasks as it is known to cause issues with Presto and Hive tests | ||||||||
project.getPlugins().withType(JacocoPlugin.class, (jacocoPlugin) -> { | ||||||||
Defaults.DEFAULT_PLATFORMS.forEach(platform -> { | ||||||||
|
@@ -119,6 +122,7 @@ private SourceSet configureSourceSet(Project project, Platform platform, SourceS | |||||||
Path wrapperResourceOutputDir = platformBaseDir.resolve("resources"); | ||||||||
|
||||||||
return javaConvention.getSourceSets().create(platform.getName(), sourceSet -> { | ||||||||
|
||||||||
/* | ||||||||
Creates a SourceSet and set the source directories for a given platform. E.g. For the Presto platform, | ||||||||
|
||||||||
|
@@ -192,9 +196,33 @@ private TaskProvider<GenerateWrappersTask> configureGenerateWrappersTask(Project | |||||||
task.dependsOn(project.getTasks().named(inputSourceSet.getClassesTaskName())); | ||||||||
}); | ||||||||
|
||||||||
project.getTasks() | ||||||||
.named(outputSourceSet.getCompileTaskName(platform.getLanguage().toString())) | ||||||||
.configure(task -> task.dependsOn(generateWrappersTask)); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we leave this as is and then replace the switch block below with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||||||||
|
||||||||
switch (platform.getLanguage()) { | ||||||||
case JAVA: | ||||||||
project.getTasks() | ||||||||
.named(outputSourceSet.getCompileTaskName(platform.getLanguage().toString()), JavaCompile.class) | ||||||||
.configure(task -> { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||||||||
task.dependsOn(generateWrappersTask); | ||||||||
// configure compile task to run with platform specific jdk | ||||||||
JavaToolchainService javaToolchains = project.getExtensions().getByType(JavaToolchainService.class); | ||||||||
task.getJavaCompiler().set(javaToolchains.compilerFor(toolChainSpec -> { | ||||||||
toolChainSpec.getLanguageVersion().set(platform.getJavaLanguageVersion()); | ||||||||
})); | ||||||||
}); | ||||||||
break; | ||||||||
case SCALA: | ||||||||
default: | ||||||||
project.getTasks() | ||||||||
.named(outputSourceSet.getCompileTaskName(platform.getLanguage().toString())) | ||||||||
.configure(task -> { | ||||||||
task.dependsOn(generateWrappersTask); | ||||||||
// todo: configure task to run with platform specific jdk (currently picks from local env) | ||||||||
// Toolchain support is only available in the Java plugins and for the tasks they define. | ||||||||
// Support for the Scala plugin is not released yet. | ||||||||
// Ref: https://docs.gradle.org/7.0/userguide/toolchains.html#sec:consuming | ||||||||
}); | ||||||||
break; | ||||||||
} | ||||||||
|
||||||||
return generateWrappersTask; | ||||||||
} | ||||||||
|
@@ -257,6 +285,12 @@ task prestoTest(type: Test, dependsOn: test) { | |||||||
task.setClasspath(testClasspath); | ||||||||
task.useTestNG(); | ||||||||
task.mustRunAfter(project.getTasks().named("test")); | ||||||||
|
||||||||
// configure test task to run with platform specific jdk | ||||||||
JavaToolchainService javaToolchains = project.getExtensions().getByType(JavaToolchainService.class); | ||||||||
task.getJavaLauncher().set(javaToolchains.launcherFor(toolChainSpec -> { | ||||||||
toolChainSpec.getLanguageVersion().set(platform.getJavaLanguageVersion()); | ||||||||
})); | ||||||||
}); | ||||||||
} | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this change is no longer needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed