From a6800b7590fee01425051b1d3bdb404b17e96b67 Mon Sep 17 00:00:00 2001 From: Chad Wilson Date: Thu, 7 May 2020 23:16:11 +0800 Subject: [PATCH] Fix `DelombokTask` and `InstallLombokTask` under Gradle 6.4 by setting main during `configure` phase --- .../gradle/lombok/task/DelombokTask.groovy | 17 +++++++++-------- .../gradle/lombok/task/InstallLombokTask.groovy | 15 ++++++++------- .../lombok/CompatibilityIntegrationTest.groovy | 1 + .../gradle/lombok/task/DelombokTaskSpec.groovy | 1 + .../lombok/task/InstallLombokTaskSpec.groovy | 1 + 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/gradle-lombok-plugin/src/main/groovy/io/franzbecker/gradle/lombok/task/DelombokTask.groovy b/gradle-lombok-plugin/src/main/groovy/io/franzbecker/gradle/lombok/task/DelombokTask.groovy index 00864f7..8984fe2 100644 --- a/gradle-lombok-plugin/src/main/groovy/io/franzbecker/gradle/lombok/task/DelombokTask.groovy +++ b/gradle-lombok-plugin/src/main/groovy/io/franzbecker/gradle/lombok/task/DelombokTask.groovy @@ -1,7 +1,8 @@ package io.franzbecker.gradle.lombok.task -import io.franzbecker.gradle.lombok.LombokPlugin + import io.franzbecker.gradle.lombok.LombokPluginExtension +import org.gradle.api.Task import org.gradle.api.plugins.JavaPlugin import org.gradle.api.tasks.Input import org.gradle.api.tasks.JavaExec @@ -21,14 +22,14 @@ class DelombokTask extends JavaExec { } @Override - void exec() { - // Retrieve extension and configuration - def extension = project.extensions.findByType(LombokPluginExtension) - def compile = project.configurations.getByName(compileConfigurationName) + Task configure(Closure closure) { + setMain(project.extensions.findByType(LombokPluginExtension).main) + return super.configure(closure) + } - // Configure JavaExec - setMain(extension.main) - classpath(compile) + @Override + void exec() { + classpath(project.configurations.getByName(compileConfigurationName)) super.exec() } diff --git a/gradle-lombok-plugin/src/main/groovy/io/franzbecker/gradle/lombok/task/InstallLombokTask.groovy b/gradle-lombok-plugin/src/main/groovy/io/franzbecker/gradle/lombok/task/InstallLombokTask.groovy index 9f81c2d..19c3486 100644 --- a/gradle-lombok-plugin/src/main/groovy/io/franzbecker/gradle/lombok/task/InstallLombokTask.groovy +++ b/gradle-lombok-plugin/src/main/groovy/io/franzbecker/gradle/lombok/task/InstallLombokTask.groovy @@ -1,6 +1,7 @@ package io.franzbecker.gradle.lombok.task import io.franzbecker.gradle.lombok.LombokPlugin import io.franzbecker.gradle.lombok.LombokPluginExtension +import org.gradle.api.Task import org.gradle.api.tasks.JavaExec /** @@ -11,16 +12,16 @@ class InstallLombokTask extends JavaExec { static final String NAME = "installLombok" @Override - void exec() { - // Retrieve extension and configuration - def extension = project.extensions.findByType(LombokPluginExtension) - def configuration = project.configurations.getByName(LombokPlugin.LOMBOK_CONFIGURATION_NAME) + Task configure(Closure closure) { + setMain(project.extensions.findByType(LombokPluginExtension).main) + return super.configure(closure) + } + @Override + void exec() { // Configure JavaExec - setMain(extension.main) setIgnoreExitValue(true) - setClasspath(configuration) - + setClasspath(project.configurations.getByName(LombokPlugin.LOMBOK_CONFIGURATION_NAME)) super.exec() } diff --git a/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/CompatibilityIntegrationTest.groovy b/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/CompatibilityIntegrationTest.groovy index 7189da9..2976b76 100644 --- a/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/CompatibilityIntegrationTest.groovy +++ b/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/CompatibilityIntegrationTest.groovy @@ -35,6 +35,7 @@ class CompatibilityIntegrationTest extends AbstractIntegrationTest { '4.2.1' || 'build/classes/java' '4.7' || 'build/classes/java' '5.4' || 'build/classes/java' + '6.4' || 'build/classes/java' } } diff --git a/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/task/DelombokTaskSpec.groovy b/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/task/DelombokTaskSpec.groovy index 2913faa..654358a 100644 --- a/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/task/DelombokTaskSpec.groovy +++ b/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/task/DelombokTaskSpec.groovy @@ -14,6 +14,7 @@ class DelombokTaskSpec extends AbstractJavaExecTaskSpec { def expectedClasspath = project.configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME) when: "task executes" + task.configure {} task.exec() then: "Delombok main is called" diff --git a/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/task/InstallLombokTaskSpec.groovy b/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/task/InstallLombokTaskSpec.groovy index 79c6b1f..bf36032 100644 --- a/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/task/InstallLombokTaskSpec.groovy +++ b/gradle-lombok-plugin/src/test/groovy/io/franzbecker/gradle/lombok/task/InstallLombokTaskSpec.groovy @@ -14,6 +14,7 @@ class InstallLombokTaskSpec extends AbstractJavaExecTaskSpec { def expectedClasspath = project.configurations.getByName(LombokPlugin.LOMBOK_CONFIGURATION_NAME) when: + task.configure {} task.exec() then: