@@ -75,55 +75,6 @@ class GrailsPluginGradlePlugin extends GrailsGradlePlugin {
7575 configureExplodedDirConfiguration(project)
7676 }
7777
78- protected String getDefaultProfile () {
79- ' web-plugin'
80- }
81-
82- /**
83- * Configures an exploded configuration that can be used to build the classpath of the application
84- * from subprojects that are plugins without constructing a JAR file
85- *
86- * @param project The project instance
87- */
88- protected void configureExplodedDirConfiguration (Project project ) {
89- ConfigurationContainer allConfigurations = project. configurations
90-
91- def runtimeConfiguration = allConfigurations. findByName(' runtimeClasspath' )
92- def explodedConfig = allConfigurations. create(' exploded' )
93- explodedConfig. extendsFrom(runtimeConfiguration)
94- if (Environment . isDevelopmentRun() && isExploded(project)) {
95- runtimeConfiguration. artifacts. clear()
96- // add the subproject classes as outputs
97- TaskContainer allTasks = project. tasks
98-
99- GroovyCompile groovyCompile = (GroovyCompile ) allTasks. findByName(' compileGroovy' )
100- ProcessResources processResources = (ProcessResources ) allTasks. findByName(' processResources' )
101-
102- runtimeConfiguration. artifacts. add(new ExplodedDir (groovyCompile. destinationDirectory. get(). asFile, groovyCompile, processResources))
103- explodedConfig. artifacts. add(new ExplodedDir (processResources. destinationDir, groovyCompile, processResources))
104- }
105- }
106-
107- @CompileDynamic
108- private boolean isExploded (Project project ) {
109- Boolean . valueOf(project. properties. getOrDefault(' exploded' , ' false' ). toString())
110- }
111-
112- @Override
113- protected Task createBuildPropertiesTask (Project project ) {
114- // no-op
115- }
116-
117- @CompileStatic
118- protected void configureSourcesJarTask (Project project ) {
119- def taskContainer = project. tasks
120- if (taskContainer. findByName(' sourcesJar' ) == null ) {
121- def jarTask = taskContainer. create(' sourcesJar' , Jar )
122- jarTask. archiveClassifier. set(' sources' )
123- jarTask. from SourceSets . findMainSourceSet(project). allSource
124- }
125- }
126-
12778 @Override
12879 protected void applySpringBootPlugin (Project project ) {
12980 super . applySpringBootPlugin(project)
@@ -135,6 +86,19 @@ class GrailsPluginGradlePlugin extends GrailsGradlePlugin {
13586 }
13687 }
13788
89+ protected void checkForConfigurationClash (Project project ) {
90+ File yamlConfig = new File (project. projectDir, " ${ grailsAppDir} /conf/plugin.yml" )
91+ File groovyConfig = new File (project. projectDir, " ${ grailsAppDir} /conf/plugin.groovy" )
92+ if (yamlConfig. exists() && groovyConfig. exists()) {
93+ throw new RuntimeException (' A plugin may define a plugin.yml or a plugin.groovy, but not both' )
94+ }
95+ }
96+
97+ @Override
98+ protected Task createBuildPropertiesTask (Project project ) {
99+ // no-op
100+ }
101+
138102 @CompileDynamic
139103 protected void configureAstSources (Project project ) {
140104 SourceSet mainSourceSet = SourceSets . findMainSourceSet(project)
@@ -187,53 +151,83 @@ class GrailsPluginGradlePlugin extends GrailsGradlePlugin {
187151 }
188152 }
189153
190- protected void configurePluginJarTask (Project project ) {
191- Jar jarTask = (Jar ) project. tasks. findByName(' jar' )
192- jarTask. archiveClassifier. set(' plugin' )
193- // re-enable, since Boot disable this
194- project. getTasks(). getByName(JavaPlugin . JAR_TASK_NAME ). setEnabled(true )
195- jarTask. exclude ' application.yml'
196- jarTask. exclude ' application.groovy'
197- jarTask. exclude ' logback.groovy'
198- jarTask. exclude ' logback.xml'
199- }
200-
201154 @CompileDynamic
202155 protected void configurePluginResources (Project project ) {
203156 project. afterEvaluate {
204157 ProcessResources processResources = (ProcessResources ) project. tasks. getByName(' processResources' )
205-
206158 def processResourcesDependencies = []
207-
208- processResourcesDependencies << project. task(type : Copy , ' copyCommands' ) {
209- from " ${ project.projectDir} /src/main/scripts"
210- into " ${ processResources.destinationDir} /META-INF/commands"
159+ processResourcesDependencies << project. tasks. register(' copyCommands' , Copy ) {
160+ it. from " ${ project.projectDir} /src/main/scripts"
161+ it. into " ${ processResources.destinationDir} /META-INF/commands"
211162 }
212-
213- processResourcesDependencies << project. task(type : Copy , ' copyTemplates' ) {
214- from " ${ project.projectDir} /src/main/templates"
215- into " ${ processResources.destinationDir} /META-INF/templates"
163+ processResourcesDependencies << project. tasks. register(' copyTemplates' , Copy ) {
164+ it. from " ${ project.projectDir} /src/main/templates"
165+ it. into " ${ processResources.destinationDir} /META-INF/templates"
216166 }
167+
217168 processResources. setDuplicatesStrategy(DuplicatesStrategy . INCLUDE )
218169 processResources. dependsOn(* processResourcesDependencies)
219- project. processResources {
220- exclude ' spring/resources.groovy'
221- exclude ' **/*.gsp'
170+ processResources. exclude(' spring/resources.groovy' , ' **/*.gsp' )
171+ }
172+ }
173+
174+ protected void configurePluginJarTask (Project project ) {
175+ project. tasks. named(JavaPlugin . JAR_TASK_NAME , Jar ). configure { Jar jarTask ->
176+ jarTask. enabled = true
177+ jarTask. archiveClassifier. set(' plugin' )
178+ jarTask. exclude(' application.yml' , ' application.groovy' , ' logback.groovy' , ' logback.xml' )
179+ }
180+ }
181+
182+ @CompileStatic
183+ protected void configureSourcesJarTask (Project project ) {
184+ def taskContainer = project. tasks
185+ if (taskContainer. findByName(' sourcesJar' ) == null ) {
186+ taskContainer. register(' sourcesJar' , Jar ). configure { Jar jarTask ->
187+ jarTask. archiveClassifier. set(' sources' )
188+ jarTask. from SourceSets . findMainSourceSet(project). allSource
222189 }
223190 }
224191 }
225192
193+ /**
194+ * Configures an exploded configuration that can be used to build the classpath of the application
195+ * from subprojects that are plugins without constructing a JAR file
196+ *
197+ * @param project The project instance
198+ */
199+ protected void configureExplodedDirConfiguration (Project project ) {
200+ ConfigurationContainer allConfigurations = project. configurations
201+
202+ def runtimeConfiguration = allConfigurations. findByName(' runtimeClasspath' )
203+ def explodedConfig = allConfigurations. create(' exploded' )
204+ explodedConfig. extendsFrom(runtimeConfiguration)
205+ if (Environment . isDevelopmentRun() && isExploded(project)) {
206+ runtimeConfiguration. artifacts. clear()
207+ // add the subproject classes as outputs
208+ TaskContainer allTasks = project. tasks
209+
210+ GroovyCompile groovyCompile = (GroovyCompile ) allTasks. findByName(' compileGroovy' )
211+ ProcessResources processResources = (ProcessResources ) allTasks. findByName(' processResources' )
212+
213+ runtimeConfiguration. artifacts. add(new ExplodedDir (groovyCompile. destinationDirectory. get(). asFile, groovyCompile, processResources))
214+ explodedConfig. artifacts. add(new ExplodedDir (processResources. destinationDir, groovyCompile, processResources))
215+ }
216+ }
217+
226218 @Override
227219 protected GrailsProjectType getGrailsProjectType () {
228220 GrailsProjectType . PLUGIN
229221 }
230222
231- protected void checkForConfigurationClash (Project project ) {
232- File yamlConfig = new File (project. projectDir, " ${ grailsAppDir} /conf/plugin.yml" )
233- File groovyConfig = new File (project. projectDir, " ${ grailsAppDir} /conf/plugin.groovy" )
234- if (yamlConfig. exists() && groovyConfig. exists()) {
235- throw new RuntimeException (' A plugin may define a plugin.yml or a plugin.groovy, but not both' )
236- }
223+ @Override
224+ protected String getDefaultProfile () {
225+ ' web-plugin'
226+ }
227+
228+ @CompileDynamic
229+ private boolean isExploded (Project project ) {
230+ Boolean . valueOf(project. properties. getOrDefault(' exploded' , ' false' ). toString())
237231 }
238232
239233 static class ExplodedDir implements PublishArtifact {
0 commit comments