Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default import of java.time.* #346

Merged
merged 7 commits into from
Nov 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move java.time configuration into confiugre groovy
codeconsole committed Nov 8, 2024
commit 440ee26ca7d1bd5523a5f605fad7d7d9592d21f0
Original file line number Diff line number Diff line change
@@ -142,8 +142,6 @@ class GrailsGradlePlugin extends GroovyPlugin {

configureRunCommand(project)

configureJavaTime(project)

configurePathingJar(project)
}

@@ -291,6 +289,28 @@ class GrailsGradlePlugin extends GroovyPlugin {
}
}
}

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
}
}
}
}
}

@CompileStatic
@@ -654,31 +674,6 @@ class GrailsGradlePlugin extends GroovyPlugin {
output?.classesDirs ?: project.files(new File(project.buildDir, "classes/main"))
}

protected void configureJavaTime(Project project) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I meant to keep this method (although with a different name), and call it from the configureGroovy method.

protected void configureGroovy(Project project) {
     // some other stuff

    if (grailsExt.autoImportDateTimeApi) {
        autoImportDateTimeApi(project)
    }
}

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
}
}
}
}
}

@CompileDynamic
protected void configurePathingJar(Project project) {
project.afterEvaluate {