You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ma...@apache.org on 2025/12/16 15:38:17 UTC

(grails-core) branch issue-15286 created (now 48ba3b2c79)

This is an automated email from the ASF dual-hosted git repository.

matrei pushed a change to branch issue-15286
in repository https://gitbox.apache.org/repos/asf/grails-core.git


      at 48ba3b2c79 fix: add app class to `urlMappingsReport` task args

This branch includes the following new commits:

     new 48ba3b2c79 fix: add app class to `urlMappingsReport` task args

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(grails-core) 01/01: fix: add app class to `urlMappingsReport` task args

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

matrei pushed a commit to branch issue-15286
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 48ba3b2c79b1c7b5868da7cf783b7b8433848dcc
Author: Mattias Reichel <ma...@gmail.com>
AuthorDate: Tue Dec 16 16:37:43 2025 +0100

    fix: add app class to `urlMappingsReport` task args
---
 .../gradle/plugin/core/GrailsGradlePlugin.groovy   | 11 +++++++-
 .../gradle/plugin/web/GrailsWebGradlePlugin.groovy | 30 ++++++++++++----------
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
index b7c5c5d37d..31ca753ea2 100644
--- a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
+++ b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
@@ -173,7 +173,7 @@ class GrailsGradlePlugin extends GroovyPlugin {
         }
     }
 
-    private static Provider<String> getMainClassProvider(Project project) {
+    protected static Provider<String> getMainClassProvider(Project project) {
         Provider<FindMainClassTask> findMainClassTask = project.tasks.named('findMainClass', FindMainClassTask)
         project.provider {
             File cacheFile = findMainClassTask.get().mainClassCacheFile.orNull?.asFile
@@ -855,6 +855,15 @@ class GrailsGradlePlugin extends GroovyPlugin {
         fileCollection
     }
 
+    protected FileCollection buildClasspath(Project project, String... configurationNames) {
+        buildClasspath(
+                project,
+                configurationNames.collect {
+                    project.configurations.named(it).get()
+                } as Configuration[]
+        )
+    }
+
     @CompileStatic
     private static final class OnlyOneGrailsPlugin {
         String pluginClassname
diff --git a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/web/GrailsWebGradlePlugin.groovy b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/web/GrailsWebGradlePlugin.groovy
index a42fe686df..eb210b1b9f 100644
--- a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/web/GrailsWebGradlePlugin.groovy
+++ b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/web/GrailsWebGradlePlugin.groovy
@@ -20,12 +20,10 @@ package org.grails.gradle.plugin.web
 
 import javax.inject.Inject
 
-import groovy.transform.CompileDynamic
 import groovy.transform.CompileStatic
 
 import org.gradle.api.Project
-import org.gradle.api.file.FileCollection
-import org.gradle.api.tasks.TaskContainer
+import org.gradle.process.CommandLineArgumentProvider
 import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
 
 import grails.util.Environment
@@ -46,19 +44,25 @@ class GrailsWebGradlePlugin extends GrailsGradlePlugin {
         super(registry)
     }
 
-    @CompileDynamic
     @Override
     void apply(Project project) {
         super.apply(project)
-
-        TaskContainer taskContainer = project.tasks
-        if (taskContainer.findByName('urlMappingsReport') == null) {
-            FileCollection fileCollection = buildClasspath(project, project.configurations.runtimeClasspath, project.configurations.console)
-            taskContainer.create('urlMappingsReport', ApplicationContextCommandTask) {
-                classpath = fileCollection
-                systemProperty(Environment.KEY, System.getProperty(Environment.KEY, Environment.DEVELOPMENT.getName()))
-                command = 'url-mappings-report'
-            }
+        project.tasks.register('urlMappingsReport', ApplicationContextCommandTask) { task ->
+            task.classpath = buildClasspath(
+                    project,
+                    'runtimeClasspath', 'console'
+            )
+            task.systemProperty(
+                    Environment.KEY,
+                    System.getProperty(
+                            Environment.KEY,
+                            Environment.DEVELOPMENT.name
+                    )
+            )
+            def appClassProvider = GrailsGradlePlugin.getMainClassProvider(project)
+            task.argumentProviders.add({
+                ['url-mappings-report', appClassProvider.get()]
+            } as CommandLineArgumentProvider)
         }
     }
 }