diff --git a/gradle.properties b/gradle.properties index 63597b119..2b1b07499 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,6 +15,7 @@ projectUrl=https://views.grails.org projectVersion=3.0.0-SNAPSHOT servletApiVersion=4.0.1 spockVersion=2.1-groovy-3.0 +springBootVersion=2.7.12 springDependencyManagementPluginVersion=1.1.0 testingSupportVersion=3.0.0-RC1 diff --git a/gradle/build.gradle b/gradle/build.gradle index 1cc711c2b..85330bad8 100644 --- a/gradle/build.gradle +++ b/gradle/build.gradle @@ -24,6 +24,7 @@ repositories { dependencies { compileOnly gradleApi() + api "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion" api "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" api "org.codehaus.groovy:groovy:$groovyVersion" } diff --git a/gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplateCompileTask.groovy b/gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplateCompileTask.groovy index 9ed6dc1dd..1504001c4 100644 --- a/gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplateCompileTask.groovy +++ b/gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplateCompileTask.groovy @@ -65,7 +65,7 @@ abstract class AbstractGroovyTemplateCompileTask extends AbstractCompile { @Override @CompileDynamic void execute(JavaExecSpec javaExecSpec) { - javaExecSpec.setMain(getCompilerName()) + javaExecSpec.mainClass.set(getCompilerName()) javaExecSpec.setClasspath(getClasspath()) def jvmArgs = compileOptions.forkOptions.jvmArgs diff --git a/gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplatePlugin.groovy b/gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplatePlugin.groovy index 21f549aa4..d00931392 100644 --- a/gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplatePlugin.groovy +++ b/gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplatePlugin.groovy @@ -8,14 +8,15 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.artifacts.Configuration -import org.gradle.api.file.CopySpec import org.gradle.api.file.FileCollection 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.grails.gradle.plugin.core.GrailsExtension +import org.grails.gradle.plugin.core.IntegrationTestGradlePlugin import org.grails.gradle.plugin.util.SourceSets +import org.springframework.boot.gradle.plugin.ResolveMainClassName +import org.springframework.boot.gradle.plugin.SpringBootPlugin /** * Abstract implementation of a plugin that compiles views @@ -47,7 +48,7 @@ class AbstractGroovyTemplatePlugin implements Plugin { def allTasks = project.tasks def upperCaseName = GrailsNameUtils.getClassName(fileExtension) - AbstractGroovyTemplateCompileTask templateCompileTask = (AbstractGroovyTemplateCompileTask)allTasks.create("compile${upperCaseName}Views".toString(), (Class)taskClass) + AbstractGroovyTemplateCompileTask templateCompileTask = (AbstractGroovyTemplateCompileTask) allTasks.register("compile${upperCaseName}Views".toString(), (Class) taskClass).get() SourceSet mainSourceSet = SourceSets.findMainSourceSet(project) @@ -55,22 +56,22 @@ class AbstractGroovyTemplatePlugin implements Plugin { FileCollection classesDir = resolveClassesDirs(output, project) File destDir = new File(project.buildDir, "${templateCompileTask.fileExtension}-classes/main") output?.dir(destDir) - Configuration providedConfig = project.configurations.findByName('provided') + Configuration providedConfig = project.configurations.named('provided').get() - FileCollection allClasspath + FileCollection allClasspath = project.objects.fileCollection() 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", "${project.projectDir}/gsp-classes", pathingJar.archivePath) + Jar pathingJar = (Jar) allTasks.named('pathingJar').get() + allClasspath += project.files("${project.buildDir}/classes/groovy/main", "${project.buildDir}/resources/main", "${project.projectDir}/gsp-classes", pathingJar.archiveFile.get().asFile) templateCompileTask.dependsOn(pathingJar) templateCompileTask.setClasspath(allClasspath) } } - allClasspath = classesDir + project.configurations.getByName('compileClasspath') + allClasspath += classesDir + project.configurations.named('compileClasspath').get() if(providedConfig) { allClasspath += providedConfig } @@ -84,11 +85,27 @@ class AbstractGroovyTemplatePlugin implements Plugin { project.file("${project.projectDir}/$pathToSource") ) - templateCompileTask.dependsOn( allTasks.findByName('classes') ) + templateCompileTask.dependsOn( allTasks.named('classes').get() ) - allTasks.withType(Jar) { Jar jar -> - if (jar.name in ['jar', 'bootJar', 'war', 'bootWar']) { - jar.dependsOn templateCompileTask + project.plugins.withType(SpringBootPlugin).configureEach {plugin -> + allTasks.withType(Jar).configureEach { Task task -> + if (task.name in ['jar', 'bootJar', 'war', 'bootWar']) { + task.dependsOn templateCompileTask + } + } + + allTasks.withType(ResolveMainClassName) + .configureEach { t -> + t.dependsOn(templateCompileTask) + } + } + + project.plugins.withType(IntegrationTestGradlePlugin).configureEach { plugin -> + allTasks.named("compileIntegrationTestGroovy") { t-> + t.dependsOn(templateCompileTask) + } + allTasks.named("integrationTest") {t -> + t.dependsOn(templateCompileTask) } } }