Skip to content

Commit

Permalink
Move java time from grails-gsp to grails-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
codeconsole committed Nov 3, 2024
1 parent 0d08d5f commit 333b05b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class GrailsGradlePlugin extends GroovyPlugin {

configureRunCommand(project)

configureJavaTime(project)

configurePathingJar(project)
}

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -69,30 +68,8 @@ class GroovyPagePlugin implements Plugin<Project> {

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)
Expand Down

0 comments on commit 333b05b

Please sign in to comment.