diff --git a/src/main/groovy/org/grails/gradle/plugin/core/GrailsPluginGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/core/GrailsPluginGradlePlugin.groovy index 0bce211e..2aaa3062 100644 --- a/src/main/groovy/org/grails/gradle/plugin/core/GrailsPluginGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/core/GrailsPluginGradlePlugin.groovy @@ -24,7 +24,6 @@ import org.gradle.api.artifacts.ConfigurationContainer import org.gradle.api.artifacts.PublishArtifact import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.internal.tasks.DefaultTaskDependency -import org.gradle.api.plugins.JavaPlugin import org.gradle.api.tasks.Copy import org.gradle.api.tasks.JavaExec import org.gradle.api.tasks.SourceSet @@ -36,7 +35,6 @@ import org.gradle.api.tasks.compile.GroovyCompile import org.gradle.language.jvm.tasks.ProcessResources import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry import org.grails.gradle.plugin.util.SourceSets -import org.springframework.boot.gradle.plugin.SpringBootPlugin import org.springframework.boot.gradle.tasks.bundling.BootJar import javax.inject.Inject @@ -68,9 +66,11 @@ class GrailsPluginGradlePlugin extends GrailsGradlePlugin { configureProjectNameAndVersionASTMetadata(project) } + configureAssembleTask(project) + configurePluginResources(project) - configurePluginJarTask(project) + configureJarTask(project) configureSourcesJarTask(project) @@ -186,14 +186,34 @@ class GrailsPluginGradlePlugin extends GrailsGradlePlugin { } } - protected void configurePluginJarTask(Project project) { - project.tasks.named(SpringBootPlugin.BOOT_JAR_TASK_NAME) { - it.enabled = false // Grails Plugins should not produce a bootJar + protected void configureAssembleTask(Project project) { + // Assemble task in Grails Plugins should only produce a plain jar + project.tasks.named('assemble') { Task assembleTask -> + def disabledTasks = [ + 'bootDistTar', + 'bootDistZip', + 'bootJar', + 'bootStartScripts', + 'bootWar', + 'bootWarMainClassName', + 'distTar', + 'distZip', + 'startScripts', + 'war' + ] + disabledTasks.each { String disabledTaskName -> + project.tasks.findByName(disabledTaskName)?.enabled = false + } + // By default the assemble task does not create a plain jar + assembleTask.dependsOn('jar') } - project.tasks.named(JavaPlugin.JAR_TASK_NAME, Jar) { - it.enabled = true - it.archiveClassifier.set('') // Remove '-plain' suffix from jar file name - it.exclude('application.yml', 'application.groovy', 'logback.groovy', 'logback.xml') + } + + protected void configureJarTask(Project project) { + project.tasks.named('jar', Jar) { Jar jarTask -> + jarTask.enabled = true + jarTask.archiveClassifier.set('') // Remove '-plain' suffix from jar file name + jarTask.exclude('application.yml', 'application.groovy', 'logback.groovy', 'logback.xml') } }