From 333b05bf861ef78758b9088e17ac737453fddaef Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sat, 2 Nov 2024 20:02:58 -0700 Subject: [PATCH] Move java time from grails-gsp to grails-plugin --- .../plugin/core/GrailsGradlePlugin.groovy | 31 +++++++++++++++++++ .../plugin/web/gsp/GroovyPagePlugin.groovy | 25 +-------------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy index db1ae17e..b094e115 100644 --- a/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy @@ -142,6 +142,8 @@ class GrailsGradlePlugin extends GroovyPlugin { configureRunCommand(project) + configureJavaTime(project) + configurePathingJar(project) } @@ -652,6 +654,35 @@ class GrailsGradlePlugin extends GroovyPlugin { output?.classesDirs ?: project.files(new File(project.buildDir, "classes/main")) } + protected void configureJavaTime(Project project) { + GrailsExtension grailsExt = project.extensions.getByType(GrailsExtension) + + println "grailsExt1 $grailsExt.javaTime" + project.tasks.withType(GroovyCompile).configureEach { groovyCompileTask -> + println "grailsExt2 $grailsExt.javaTime" + if (grailsExt.javaTime) { + println "grailsExt3 $grailsExt.javaTime" + groovyCompileTask.doFirst { + println "grailsExt4 $grailsExt.javaTime" + def configScriptStream = getClass().getResourceAsStream("/GrailsCompilerConfig.groovy") + if (configScriptStream != null) { + def tempConfigScriptFile = File.createTempFile("build/GrailsCompilerConfig", ".groovy") + tempConfigScriptFile.mkdirs() + tempConfigScriptFile.deleteOnExit() + + def existingScript = groovyCompileTask.groovyOptions.configurationScript + if (existingScript) { + tempConfigScriptFile << existingScript.text + } + + tempConfigScriptFile.text = configScriptStream.text + groovyCompileTask.groovyOptions.configurationScript = tempConfigScriptFile + } + } + } + } + } + @CompileDynamic protected void configurePathingJar(Project project) { project.afterEvaluate { diff --git a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPagePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPagePlugin.groovy index bb0e211f..8b60e656 100644 --- a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPagePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPagePlugin.groovy @@ -12,7 +12,6 @@ import org.gradle.api.tasks.SourceSet import org.gradle.api.tasks.SourceSetOutput import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.bundling.War -import org.gradle.api.tasks.compile.GroovyCompile import org.grails.gradle.plugin.core.GrailsExtension import org.grails.gradle.plugin.util.SourceSets @@ -69,30 +68,8 @@ class GroovyPagePlugin implements Plugin { compileWebappGroovyPages.setClasspath( allClasspath ) - GrailsExtension grailsExt = project.extensions.getByType(GrailsExtension) - - project.tasks.withType(GroovyCompile).configureEach { groovyCompileTask -> - if (grailsExt.javaTime) { - groovyCompileTask.doFirst { - def configScriptStream = getClass().getResourceAsStream("/GrailsCompilerConfig.groovy") - if (configScriptStream != null) { - def tempConfigScriptFile = File.createTempFile("build/GrailsCompilerConfig", ".groovy") - tempConfigScriptFile.mkdirs() - tempConfigScriptFile.deleteOnExit() - - def existingScript = groovyCompileTask.groovyOptions.configurationScript - if (existingScript) { - tempConfigScriptFile << existingScript.text - } - - tempConfigScriptFile.text = configScriptStream.text - groovyCompileTask.groovyOptions.configurationScript = tempConfigScriptFile - } - } - } - } - project.afterEvaluate { + GrailsExtension grailsExt = project.extensions.getByType(GrailsExtension) if (grailsExt.pathingJar && Os.isFamily(Os.FAMILY_WINDOWS)) { Jar pathingJar = (Jar) allTasks.findByName('pathingJar') allClasspath = project.files("${project.buildDir}/classes/groovy/main", "${project.buildDir}/resources/main", pathingJar.archiveFile)