Skip to content

Commit

Permalink
Update to Gradle 8.6, fix most warnings for Gradle 9 (#4693)
Browse files Browse the repository at this point in the history
This patch cleans up most of our accumulated warnings, updates to
Gradle 8.6, and deals with most incoming warnings in anticipating of
Gradle 9.

Updates in anticipation of Gradle 8:

 * Replace Jar.classifier with Jar.artifactClassifier
 * Replace AbstractArtifactTask.main with JavaExec.mainClass
 * Drop license plugin
 * Update Shadow and JHM plugins
 * Replace Javac CompileOptions.annotationProcessorGeneratedSourcesDirectory
   with CompileOptions.generatedSourceOutputDirectory
 * Replace Report.destination with Report.outputLocation
 * Replace JavaApplication.mainClassName with JavaApplication.mainClass
 * Make task inputs/outputs explicit for protobuf diff tasks, c++ and
   r doc tasks

Updates in anticipation of Gradle 9:

 * Remove all usage of ConfigureUtil.configureUsing
 * Replace all convention usages with corresponding plugin/extension
   references
 * Update Gradle Enterprise plugin
 * Add test dependencies on junit-platform-launcher instead of
   implicitly using gradle's copy
 * Update DiffTask to explicitly list input files

Warnings that are not fixed:

 * GWT plugin version still produces warnings around use of conventions

Fixes #3642
  • Loading branch information
niloc132 committed Feb 26, 2024
1 parent 759c0f0 commit c3d6cdb
Show file tree
Hide file tree
Showing 65 changed files with 249 additions and 274 deletions.
2 changes: 1 addition & 1 deletion Base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sourceSets {

// TODO (core#116): Gradle test fixtures
task jarTests(type: Jar, dependsOn: testClasses) {
classifier = 'tests'
archiveClassifier = 'tests'
from sourceSets.test.output
}
configurations {
Expand Down
28 changes: 14 additions & 14 deletions Generators/Generators.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ String devRoot = rootDir.absolutePath
task groovyStaticImportGenerator(type: JavaExec, dependsOn: 'classes') {
description 'Run GroovyStaticImportGenerator'

main = 'io.deephaven.libs.GroovyStaticImportGenerator'
mainClass.set 'io.deephaven.libs.GroovyStaticImportGenerator'
args devRoot, 'false'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -51,7 +51,7 @@ task groovyStaticImportGenerator(type: JavaExec, dependsOn: 'classes') {
task groovyStaticImportGeneratorAssert(type: JavaExec, dependsOn: 'classes') {
description 'Run GroovyStaticImportGenerator to assert that the generated code has not changed'

main = 'io.deephaven.libs.GroovyStaticImportGenerator'
mainClass.set 'io.deephaven.libs.GroovyStaticImportGenerator'
args devRoot, 'true'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -61,7 +61,7 @@ task groovyStaticImportGeneratorAssert(type: JavaExec, dependsOn: 'classes') {
task generateStaticCalendarMethods(type: JavaExec, dependsOn: 'classes') {
description 'Run StaticCalendarMethodsGenerator'

main = 'io.deephaven.libs.StaticCalendarMethodsGenerator'
mainClass.set 'io.deephaven.libs.StaticCalendarMethodsGenerator'
args devRoot, 'false'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -70,7 +70,7 @@ task generateStaticCalendarMethods(type: JavaExec, dependsOn: 'classes') {
task generateStaticCalendarMethodsAssert(type: JavaExec, dependsOn: 'classes') {
description 'Run StaticCalendarMethodsGenerator to assert that the generated code has not changed'

main = 'io.deephaven.libs.StaticCalendarMethodsGenerator'
mainClass.set 'io.deephaven.libs.StaticCalendarMethodsGenerator'
args devRoot, 'true'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -80,7 +80,7 @@ task generateStaticCalendarMethodsAssert(type: JavaExec, dependsOn: 'classes') {
task generateAxesPlotMethods(type: JavaExec, dependsOn: 'classes') {
description 'Run GenerateAxesPlotMethods'

main = 'io.deephaven.plot.util.GenerateAxesPlotMethods'
mainClass.set 'io.deephaven.plot.util.GenerateAxesPlotMethods'
args devRoot, 'false'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -91,7 +91,7 @@ task generateAxesPlotMethods(type: JavaExec, dependsOn: 'classes') {
task generateAxesPlotMethodsAssert(type: JavaExec, dependsOn: 'classes') {
description 'Run GenerateAxesPlotMethods to assert that the generated code has not changed'

main = 'io.deephaven.plot.util.GenerateAxesPlotMethods'
mainClass.set 'io.deephaven.plot.util.GenerateAxesPlotMethods'
args devRoot, 'true'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -103,7 +103,7 @@ task generateAxesPlotMethodsAssert(type: JavaExec, dependsOn: 'classes') {
task generateMultiSeries(type: JavaExec, dependsOn: 'classes') {
description 'Run GenerateMultiSeries'

main = 'io.deephaven.plot.util.GenerateMultiSeries'
mainClass.set 'io.deephaven.plot.util.GenerateMultiSeries'
args devRoot, 'false'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -114,7 +114,7 @@ task generateMultiSeries(type: JavaExec, dependsOn: 'classes') {
task generateMultiSeriesAssert(type: JavaExec, dependsOn: 'classes') {
description 'Run GenerateMultiSeries to assert that the generated code has not changed'

main = 'io.deephaven.plot.util.GenerateMultiSeries'
mainClass.set 'io.deephaven.plot.util.GenerateMultiSeries'
args devRoot, 'true'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -127,7 +127,7 @@ task generateFigureImmutable(type: JavaExec, dependsOn: 'classes') {
description 'Run GenerateFigureImmutable'
dependsOn generateAxesPlotMethods, generateMultiSeries

main = 'io.deephaven.plot.util.GenerateFigureImmutable'
mainClass.set 'io.deephaven.plot.util.GenerateFigureImmutable'
args devRoot, 'false'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -139,7 +139,7 @@ task generateFigureImmutableAssert(type: JavaExec, dependsOn: 'classes') {
description 'Run GenerateFigureImmutable to assert that the generated code has not changed'
dependsOn generateAxesPlotMethodsAssert, generateMultiSeriesAssert

main = 'io.deephaven.plot.util.GenerateFigureImmutable'
mainClass.set 'io.deephaven.plot.util.GenerateFigureImmutable'
args devRoot, 'true'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -152,7 +152,7 @@ task generatePlottingConvenience(type: JavaExec, dependsOn: 'classes') {
description 'Run GeneratePlottingConvenience'
dependsOn generateFigureImmutable

main = 'io.deephaven.plot.util.GeneratePlottingConvenience'
mainClass.set 'io.deephaven.plot.util.GeneratePlottingConvenience'
args devRoot
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -164,7 +164,7 @@ task generatePlottingConvenienceAssert(type: JavaExec, dependsOn: 'classes') {
description 'Run GeneratePlottingConvenience to assert that the generated code has not changed'
dependsOn generateFigureImmutableAssert

main = 'io.deephaven.plot.util.GeneratePlottingConvenience'
mainClass.set 'io.deephaven.plot.util.GeneratePlottingConvenience'
args devRoot, 'true'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -176,7 +176,7 @@ task generatePythonFigureWrapper(type: JavaExec, dependsOn: 'classes') {
description 'Run GeneratePythonFigureWrapper'
dependsOn generatePlottingConvenience

main = 'io.deephaven.plot.util.GeneratePyV2FigureAPI'
mainClass.set 'io.deephaven.plot.util.GeneratePyV2FigureAPI'
args devRoot, 'false'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand All @@ -189,7 +189,7 @@ task generatePythonFigureWrapperAssert(type: JavaExec, dependsOn: 'classes') {
description 'Run GeneratePythonFigureWrapper'
dependsOn generatePlottingConvenienceAssert

main = 'io.deephaven.plot.util.GeneratePyV2FigureAPI'
mainClass.set 'io.deephaven.plot.util.GeneratePyV2FigureAPI'
args devRoot, 'true'
classpath = sourceSets.main.runtimeClasspath
workingDir = workDir
Expand Down
2 changes: 1 addition & 1 deletion IO/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sourceSets {

// TODO (core#116): Gradle test fixtures
task jarTests(type: Jar, dependsOn: testClasses) {
classifier = 'tests'
archiveClassifier = 'tests'
from sourceSets.test.output
}
configurations {
Expand Down
8 changes: 6 additions & 2 deletions Integrations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ sourceSets {
}
}

JavaPluginConvention java = project.convention.plugins.get('java') as JavaPluginConvention
SourceSet test = java.sourceSets.maybeCreate('test')
SourceSet test = extensions.findByType(JavaPluginExtension).sourceSets.maybeCreate('test')

def runInDocker = { String name, String sourcePath, List<String> command, Closure addConfig = {} ->
Docker.registerDockerTask(project, name) {
copyIn {
from(sourcePath) {
include 'deephaven/**'
include 'deephaven_internal/**'
include 'test_helper/**'
include 'tests/**'
include 'setup.py'
into 'python'
}
from(test.runtimeClasspath) {
Expand Down
1 change: 1 addition & 0 deletions R/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def rClientSite = Docker.registerDockerTask(project, 'rClientSite') {
// Only tested on x86-64, and we only build dependencies for x86-64
platform = 'linux/amd64'
copyIn {
mustRunAfter(rClientDoc)
from(layout.projectDirectory) {
include 'r-site.sh'
include 'rdeephaven/man/**'
Expand Down
1 change: 1 addition & 0 deletions Util/Util.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ dependencies {
testImplementation project(':base-test-utils')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
1 change: 1 addition & 0 deletions Util/channel/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
Classpaths.inheritAssertJ(project)
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

test {
Expand Down
1 change: 1 addition & 0 deletions Util/function/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
Classpaths.inheritAssertJ(project)
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

test {
Expand Down
2 changes: 1 addition & 1 deletion authentication/example-providers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ project.subprojects { Project p ->
p.tasks.findByName('assemble').dependsOn(p.tasks.named('shadowJar'))

// Let projects be named consistently
p.archivesBaseName = "deephaven-${p.name}-authentication-provider"
p.base.archivesName = "deephaven-${p.name}-authentication-provider"
}
9 changes: 2 additions & 7 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
implementation('de.esoco.gwt:gwt-gradle-plugin:1.1.1') {
implementation('de.esoco.gwt:gwt-gradle-plugin:1.2.0') {
exclude group: 'org.codehaus.groovy'
because('needed for GwtTools')
}
Expand All @@ -34,10 +34,5 @@ dependencies {
because('needed by plugin java-coding-conventions')
}

// TODO(deephaven-core#1997): Remove license-gradle-plugin
implementation('gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.16.1') {
because('needed by plugin java-header-conventions')
}

implementation "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
implementation "com.github.johnrengelman:shadow:8.1.1"
}
1 change: 0 additions & 1 deletion buildSrc/src/main/groovy/Classpaths.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.Dependency
import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency
import org.gradle.api.plugins.JavaPlatformPlugin
import org.gradle.api.plugins.JavaPlugin
import org.gradle.internal.Actions

Expand Down
51 changes: 26 additions & 25 deletions buildSrc/src/main/groovy/Docker.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import org.gradle.api.file.CopySpec
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.Sync
import org.gradle.api.tasks.TaskProvider
import org.gradle.util.ConfigureUtil

/**
* Tools to make some common tasks in docker easier to use in gradle
Expand Down Expand Up @@ -72,13 +71,18 @@ class Docker {
/**
* DSL object to describe a docker task
*/
static class DockerTaskConfig {
abstract static class DockerTaskConfig {

private Action<? super CopySpec> copyIn;
private Action<? super Sync> copyOut;
private File dockerfileFile;
private Action<? super Dockerfile> dockerfileAction;
private TaskDependencies containerDependencies = new TaskDependencies();

/**
* Declares tasks that this group of tasks should depend on or be
* finalized by.
*/
TaskDependencies containerDependencies = new TaskDependencies();

/**
* Files that need to be copied in to the image.
Expand All @@ -87,12 +91,6 @@ class Docker {
copyIn = action;
return this;
}
/**
* Files that need to be copied in to the image.
*/
DockerTaskConfig copyIn(Closure closure) {
return copyIn(ConfigureUtil.configureUsing(closure))
}

/**
* Resulting files to copy out from the containerOutPath.
Expand All @@ -101,12 +99,6 @@ class Docker {
copyOut = action;
return this;
}
/**
* Resulting files to copy out from the containerOutPath.
*/
DockerTaskConfig copyOut(Closure closure) {
return copyOut(ConfigureUtil.configureUsing(closure))
}

/**
* Dockerfile to use. If not set, it is assumed that a dockerfile will be included in copyIn.
Expand All @@ -122,12 +114,6 @@ class Docker {
this.dockerfileAction = action;
return this;
}
/**
* Dockerfile to use. If not set, it is assumed that a dockerfile will be included in copyIn.
*/
DockerTaskConfig dockerfile(Closure closure) {
dockerfile(ConfigureUtil.configureUsing(closure));
}

/**
* Tag to apply to the created image. Defaults to "deephaven/" followed by the task name.
Expand Down Expand Up @@ -208,7 +194,12 @@ class Docker {
* @return a task provider for the Sync task that will produce the requested output
*/
static TaskProvider<? extends Task> registerDockerTask(Project project, String taskName, Closure closure) {
return registerDockerTask(project, taskName, ConfigureUtil.configureUsing(closure))
return registerDockerTask(project, taskName, new Action<DockerTaskConfig>() {
@Override
void execute(DockerTaskConfig dockerTaskConfig) {
project.configure(dockerTaskConfig, closure)
}
})
}

/**
Expand All @@ -221,7 +212,7 @@ class Docker {
*/
static TaskProvider<? extends Task> registerDockerTask(Project project, String taskName, Action<? super DockerTaskConfig> action) {
// create instance, assign defaults
DockerTaskConfig cfg = new DockerTaskConfig();
DockerTaskConfig cfg = project.objects.newInstance(DockerTaskConfig);
cfg.imageName = "deephaven/${taskName.replaceAll(/\B[A-Z]/) { String str -> '-' + str }.toLowerCase()}:${LOCAL_BUILD_TAG}"

// ask for more configuration
Expand Down Expand Up @@ -576,7 +567,12 @@ class Docker {
}

static TaskProvider<? extends DockerBuildImage> registerDockerTwoPhaseImage(Project project, String baseName, String intermediate, Closure closure) {
return registerDockerTwoPhaseImage(project, baseName, intermediate, ConfigureUtil.configureUsing(closure))
return registerDockerTwoPhaseImage(project, baseName, intermediate, new Action<DockerBuildImage>() {
@Override
void execute(DockerBuildImage dockerBuildImage) {
project.configure(dockerBuildImage, closure)
}
})
}

static TaskProvider<? extends DockerBuildImage> registerDockerTwoPhaseImage(Project project, String baseName, String intermediate, Action<? super DockerBuildImage> action) {
Expand All @@ -598,7 +594,12 @@ class Docker {
}

static TaskProvider<? extends DockerBuildImage> registerDockerImage(Project project, String taskName, Closure closure) {
return registerDockerImage(project, taskName, ConfigureUtil.configureUsing(closure))
return registerDockerImage(project, taskName, new Action<DockerBuildImage>() {
@Override
void execute(DockerBuildImage dockerBuildImage) {
project.configure(dockerBuildImage, closure)
}
})
}

static TaskProvider<? extends DockerBuildImage> registerDockerImage(Project project, String taskName, Action<? super DockerBuildImage> action) {
Expand Down
12 changes: 5 additions & 7 deletions buildSrc/src/main/groovy/Tasks.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import groovy.transform.CompileStatic
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.TaskProvider
Expand All @@ -13,22 +13,20 @@ class Tasks {

static TaskProvider<? extends JavaExec> registerMainExecTask(Project project, String taskName, String mainClassName) {
return project.tasks.register(taskName, JavaExec) { task ->
JavaPluginConvention java = project.convention.plugins.get('java') as JavaPluginConvention
SourceSet sourceSet = java.sourceSets.getByName('main')
SourceSet sourceSet = project.extensions.findByType(JavaPluginExtension).sourceSets.getByName('main')
task.workingDir project.rootDir
task.classpath = sourceSet.runtimeClasspath
task.main = mainClassName
task.mainClass.set mainClassName
task.systemProperty 'Configuration.rootFile', 'dh-defaults.prop'
}
}

static TaskProvider<? extends JavaExec> registerTestExecTask(Project project, String taskName, String mainClassName) {
return project.tasks.register(taskName, JavaExec) { task ->
JavaPluginConvention java = project.convention.plugins.get('java') as JavaPluginConvention
SourceSet sourceSet = java.sourceSets.getByName('test')
SourceSet sourceSet = project.extensions.findByType(JavaPluginExtension).sourceSets.getByName('main')
task.workingDir project.rootDir
task.classpath = sourceSet.runtimeClasspath
task.main = mainClassName
task.mainClass.set mainClassName
task.systemProperty 'Configuration.rootFile', 'dh-tests.prop'
}
}
Expand Down
Loading

0 comments on commit c3d6cdb

Please sign in to comment.