From 056f94adc5c123b9d1cbc2c6c47bf05884d49895 Mon Sep 17 00:00:00 2001 From: itsnotoger <19309683+itsnotoger@users.noreply.github.com> Date: Mon, 14 Oct 2024 00:20:54 +0200 Subject: [PATCH] Fix bug in toGDrive introduced by Gradle 8.10 * after many hours of debugging, the cause was the dubious usage of `Provider.map {}` in task configuration * previously (Gradle 8.9) it seems this method was evaluated eager, during task configuration * now it seems either the map is not evaluated at all (which it probably shouldn't), or this type of code is disallowed * the latter was indicated by certain build errors claiming something like "actions with Java lambdas are not allowed" --- build.gradle.kts | 4 ++-- src/main/kotlin/oger/util/java/GDriveExtension.kt | 1 + src/main/kotlin/oger/util/java/OgerPlugin.kt | 2 +- .../oger/util/java/plugins/ConfigureExtraJavaModule.kt | 6 ------ src/main/kotlin/oger/util/java/plugins/ConfigureL4j.kt | 3 ++- src/test/groovy/oger.util.java/ToGDriveSpec.groovy | 1 - 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 53dd028..491a5a8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "com.github.itsnotoger" -version = "0.0.1-SNAPSHOT" +version = "2.0.0-SNAPSHOT" val githubProjectName = "gradle-plugin" kotlin { @@ -46,7 +46,7 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.0") val groovyMajor = 3 - testImplementation("org.codehaus.groovy:groovy-all:${groovyMajor}.0.21") { + testImplementation("org.codehaus.groovy:groovy-all:${groovyMajor}.0.22") { because("java-gradle-plugin requires 3.x") } testImplementation("org.spockframework:spock-core:2.3-groovy-${groovyMajor}.0") diff --git a/src/main/kotlin/oger/util/java/GDriveExtension.kt b/src/main/kotlin/oger/util/java/GDriveExtension.kt index 017f2e6..0557f4d 100644 --- a/src/main/kotlin/oger/util/java/GDriveExtension.kt +++ b/src/main/kotlin/oger/util/java/GDriveExtension.kt @@ -59,6 +59,7 @@ enum class Type { LIBRARY, JARLIBRARY, MAVENLIBRARY -> true + L4JAPPLICATION, FATJARAPPLICATION -> false } diff --git a/src/main/kotlin/oger/util/java/OgerPlugin.kt b/src/main/kotlin/oger/util/java/OgerPlugin.kt index 923a5d5..20ac8a3 100644 --- a/src/main/kotlin/oger/util/java/OgerPlugin.kt +++ b/src/main/kotlin/oger/util/java/OgerPlugin.kt @@ -97,7 +97,7 @@ class OgerPlugin : Plugin { it.dependsOn("build") @Suppress("DEPRECATION") // we want to support deprecated fields - gdrive.type.map { type -> + gdrive.type.get().let { type -> when (type) { Type.INLINELIBRARY -> { it.enabled = false diff --git a/src/main/kotlin/oger/util/java/plugins/ConfigureExtraJavaModule.kt b/src/main/kotlin/oger/util/java/plugins/ConfigureExtraJavaModule.kt index 632216c..4430649 100644 --- a/src/main/kotlin/oger/util/java/plugins/ConfigureExtraJavaModule.kt +++ b/src/main/kotlin/oger/util/java/plugins/ConfigureExtraJavaModule.kt @@ -7,8 +7,6 @@ import org.gradlex.javamodule.moduleinfo.ExtraJavaModuleInfoPluginExtension object ConfigureExtraJavaModule { - var DEBUG = false - fun apply(project: Project) { val extraJavaModuleInfo = project.extensions.getByType(ExtraJavaModuleInfoPluginExtension::class.java) extraJavaModuleInfo.apply { @@ -125,13 +123,9 @@ object ConfigureExtraJavaModule { } fun disableTestClasspath(project: Project) { - if (DEBUG) println("configure test classpath for $project") project.plugins.withType(JavaPlugin::class.java) { - if (DEBUG) println("configure test classpath for java $project") listOf("testCompileClasspath", "testRuntimeClasspath").forEach { configName -> - if (DEBUG) println("configure $configName for java $project") project.configurations.named(configName).configure { - if (DEBUG) println("configure $configName for java $project attribute set") it.attributes.attribute(Attribute.of("javaModule", Boolean::class.javaObjectType), false) } } diff --git a/src/main/kotlin/oger/util/java/plugins/ConfigureL4j.kt b/src/main/kotlin/oger/util/java/plugins/ConfigureL4j.kt index 0057206..38223cd 100644 --- a/src/main/kotlin/oger/util/java/plugins/ConfigureL4j.kt +++ b/src/main/kotlin/oger/util/java/plugins/ConfigureL4j.kt @@ -19,7 +19,8 @@ object ConfigureL4j { """-Dold.user.dir="%OLDPWD%"""" ) val gdrive = project.extensions.getByType(GDriveExtension::class.java) - if (gdrive.mainClass.isPresent) mainClassName.set(gdrive.mainClass.get()) + + mainClassName.convention(gdrive.mainClass) project.plugins.findPlugin("org.openjfx.javafxplugin")?.let { jvmOptions.addAll(ConfigureJfx.getJvmOptions(libraryDir)) diff --git a/src/test/groovy/oger.util.java/ToGDriveSpec.groovy b/src/test/groovy/oger.util.java/ToGDriveSpec.groovy index e9664d7..bb9addf 100644 --- a/src/test/groovy/oger.util.java/ToGDriveSpec.groovy +++ b/src/test/groovy/oger.util.java/ToGDriveSpec.groovy @@ -36,7 +36,6 @@ class ToGDriveSpec extends Specification { id 'com.github.itsnotoger.gradle-plugin' } gdrive { - debug = true type = oger.util.java.Type.JARLIBRARY GDriveJars = "/syncme/gradle_jars" GDriveApps = "/gradle_apps"