jamesfredley commented on code in PR #11:
URL: https://github.com/apache/grails-micronaut/pull/11#discussion_r4225111569


##########
settings.gradle:
##########
@@ -27,11 +27,11 @@ pluginManagement {
         configurePluginRepositories(delegate)
     }
     plugins {
-        def grailsVersion = providers.gradleProperty('projectVersion').get()
+        def grailsVersion = providers.gradleProperty('grailsVersion').get()
         id 'org.apache.grails.gradle.grails-gsp' version grailsVersion
         id 'org.apache.grails.gradle.grails-plugin' version grailsVersion
         id 'org.apache.grails.gradle.grails-web' version grailsVersion
-        id 'cloud.wondrify.asset-pipeline' version '5.2.0-M3'
+        id 'cloud.wondrify.asset-pipeline' version '5.2.0'

Review Comment:
   Leaving this `.get()`. `grailsVersion` is always set in `gradle.properties`, 
and this is the same lookup the previous `projectVersion` property used.



##########
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy:
##########
@@ -87,7 +88,8 @@ class CompilePlugin implements Plugin<Project> {
 
             jar.manifest.attributes(
                     'Implementation-Title': 'Apache Grails',
-                    'Implementation-Version': lookupPropertyByType(project, 
'grailsVersion', String),
+                    'Implementation-Version': lookupProperty(project, 
'projectVersion',
+                            lookupPropertyByType(project, 'grailsVersion', 
String)),

Review Comment:
   The goal is to keep this repository's jar `Implementation-Version` on its 
own version after `grailsVersion` was split off as the released Grails line. 
The manifest now reads `project.version`, which the build script assigns from 
`projectVersion` (including `-PprojectVersion` on a release), so it matches the 
compiler stamp. The PR description mentions that manifest change. Fixed in 
d03db59a81.



##########
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy:
##########
@@ -145,6 +147,24 @@ class CompilePlugin implements Plugin<Project> {
                 // when both are present.
                 it.groovyOptions.configurationScript =
                         
GradleUtils.findRootGrailsCoreDir(project).file('gradle/groovy-compile-configscript.groovy').asFile
+            }
+                // Stamp this repository's published version onto compiled 
classes after the build
+                // script has assigned version. Without the stamp, the Grails 
transform falls back to
+                // grails-core's Implementation-Version, so a snapshot build 
of this plugin would
+                // advertise the released framework version. The script is 
generated by a task so
+                // `clean compileGroovy` can recreate it after `clean` deletes 
`build/`.
+            project.afterEvaluate {
+                // Applications and plugins built with the Grails Gradle 
plugin already stamp
+                // project.version. Replacing their merged compiler script 
would drop that plugin's
+                // own configuration. This repository's published plugin does 
not apply it.
+                if 
(project.plugins.hasPlugin('org.apache.grails.gradle.grails-plugin')
+                        || 
project.plugins.hasPlugin('org.apache.grails.gradle.grails-web')
+                        || 
project.plugins.hasPlugin('org.apache.grails.gradle.grails-gsp')) {
+                    return
+                }
+                project.tasks.withType(GroovyCompile).each { GroovyCompile 
compile ->

Review Comment:
   Fixed by not registering tasks while iterating `GroovyCompile`. The writer 
is registered from `sourceSets.configureEach` and wired with 
`configurationScriptFile`, so `-PprojectVersion=8.0.0` configures. 
`CompilePluginSpec` covers that release version, and CI runs `./gradlew help 
-PprojectVersion=8.0.0` before the build. Fixed in d03db59a81.



##########
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy:
##########
@@ -145,6 +147,24 @@ class CompilePlugin implements Plugin<Project> {
                 // when both are present.
                 it.groovyOptions.configurationScript =
                         
GradleUtils.findRootGrailsCoreDir(project).file('gradle/groovy-compile-configscript.groovy').asFile
+            }
+                // Stamp this repository's published version onto compiled 
classes after the build
+                // script has assigned version. Without the stamp, the Grails 
transform falls back to
+                // grails-core's Implementation-Version, so a snapshot build 
of this plugin would
+                // advertise the released framework version. The script is 
generated by a task so
+                // `clean compileGroovy` can recreate it after `clean` deletes 
`build/`.
+            project.afterEvaluate {
+                // Applications and plugins built with the Grails Gradle 
plugin already stamp
+                // project.version. Replacing their merged compiler script 
would drop that plugin's
+                // own configuration. This repository's published plugin does 
not apply it.
+                if 
(project.plugins.hasPlugin('org.apache.grails.gradle.grails-plugin')
+                        || 
project.plugins.hasPlugin('org.apache.grails.gradle.grails-web')
+                        || 
project.plugins.hasPlugin('org.apache.grails.gradle.grails-gsp')) {

Review Comment:
   Stamping is now opt-in on `org.apache.grails.buildsrc.publish`, which 
selects `:grails-micronaut`. Projects that apply the Grails Gradle plugins do 
not apply that plugin, so their compiler script is left alone. The spec covers 
that skip path. Fixed in d03db59a81.



##########
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy:
##########
@@ -155,6 +175,60 @@ class CompilePlugin implements Plugin<Project> {
         }
     }
 
+    /**
+     * Writes the Groovy compiler configuration for {@code compile}, including 
the shared
+     * reproducibility script and this project's published version.
+     *
+     * <p>The published version is captured in {@code afterEvaluate}, after 
the build script assigns
+     * {@code version}. The script file is produced by a task, not written 
during configuration, so
+     * {@code clean compileGroovy} in one invocation regenerates it after 
{@code clean} deletes
+     * {@code build/}.</p>
+     */
+    private static void configurePublishedVersionScript(Project project, 
GroovyCompile compile) {

Review Comment:
   Replaced the `afterEvaluate` / `register().get()` / `dependsOn` wiring with 
a typed task, an `@Input` version from `project.provider { 
project.version.toString() }`, an `@OutputFile`, registration per source set, 
and `configurationScriptFile.set(writer.flatMap { it.outputFile })`. Fixed in 
d03db59a81.



-- 
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]

Reply via email to