jdaugherty commented on code in PR #15601:
URL: https://github.com/apache/grails-core/pull/15601#discussion_r3150860199
##########
grails-core/src/main/groovy/org/grails/compiler/injection/GlobalGrailsClassInjectorTransformation.groovy:
##########
@@ -248,11 +250,23 @@ class GlobalGrailsClassInjectorTransformation implements
ASTTransformation, Comp
}
private static File findSourceDirectory(File compilationTargetDirectory) {
+ // Prefer the project base directory supplied by the build tool — more
reliable than
+ // walking up from the compile target, which may live under a
non-standard output
+ // directory (e.g. when project.buildDir is renamed). The Grails
Gradle plugin
+ // publishes this via GrailsAppBaseDirProvider on the compiler's
forkOptions.
+ String baseDirProp = System.getProperty('base.dir')
+ if (baseDirProp) {
+ File baseDir = new File(baseDirProp)
+ if (baseDir.isDirectory()) {
Review Comment:
should we check that the directory actually exists too?
##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:
##########
@@ -196,6 +196,12 @@ class GrailsGradlePlugin extends GroovyPlugin {
Provider<RegularFile> groovyCompilerConfigFile =
project.layout.buildDirectory.file("grailsGroovyCompilerConfig-${c.name}.groovy")
c.outputs.file(groovyCompilerConfigFile)
+ // Publish the project base directory to the Groovy compiler's
worker daemon JVM so the
+ // GlobalGrailsClassInjectorTransformation AST transform can locate
+ // src/main/resources/META-INF/grails.factories without relying on
hardcoded
+ // "build"/"target" output-directory names. Reuses the same
CommandLineArgumentProvider
+ // pattern as forked test/run tasks (see configureForkSettings).
+ c.groovyOptions.forkOptions.jvmArgumentProviders.add(new
GrailsAppBaseDirProvider(project.projectDir))
Closure<String> userScriptGenerator = getGroovyCompilerScript(c,
project)
Review Comment:
The `GrailsAppBaseDirProvider` Javadoc (line 29) says it provides
`-Dgrails.build.base.dir`, but the implementation actually provides
`-Dbase.dir`. Can you fix the javadoc while we're working with this code?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]