You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "matrei (via GitHub)" <gi...@apache.org> on 2025/11/14 11:21:54 UTC

[PR] Add versions to banner [grails-core]

matrei opened a new pull request, #15229:
URL: https://github.com/apache/grails-core/pull/15229

   (no comment)


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3544643052

   @matrei bonus points if we can get Spring Security in there? 
   ```groovy
   Class.forName('org.springframework.security.core.SpringSecurityCoreVersion').version
   ```


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "sbglasius (via GitHub)" <gi...@apache.org>.
sbglasius commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3551519325

   @matrei Since SpringSecurityCore is under Apache Grails, I agree with @codeconsole, but in any other case I would disagree too.
   
   Now that this is an open issue, how about creating a `META-INF/service/grails.banner.loader` with the name of the `GrailsBanner` class to implement, and then (I assume) SpringSecurityCore could extend `GrailsBanner` and override `META-INFO/service/grails.banner.loader` I'm not 100% sure about the load order in such case? and perhaps it's just a big overkill 😀 
   
   


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "sbglasius (via GitHub)" <gi...@apache.org>.
sbglasius commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3534366588

   Can the java-version show what distribution it comes from (Amazon, Belsoft, Oracle, etc?)
   


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "matrei (via GitHub)" <gi...@apache.org>.
matrei commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3541152977

   > looks nice, but I wonder I wonder if it should also display when banner is off? In all my apps, I have been using
   > 
   > ```groovy
   > log.info "${Metadata.current['info.app.name']}  v${Metadata.current['info.app.version']} (Java ${System.getProperty('java.version')} Groovy ${GroovySystem.getVersion()} Grails ${Metadata.current['info.app.grailsVersion']} Spring Boot ${SpringBootVersion.version} Spring ${SpringVersion.version})"
   > ```
   > 
   > because it is useful for troubleshooting to know what versions you are running. I have banner off because I don't want to fill my logs with a banner (especially when I am running multiple instances).
   > 
   > Or have a separate setting to display it if banner is off?
   
   @codeconsole See updated PR description, will this accommodate your use case?


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3544619645

   > @codeconsole See updated PR description, will this accommodate your use case?
   
   yes 😄 


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "matrei (via GitHub)" <gi...@apache.org>.
matrei commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3546391901

   > bonus points if we can get Spring Security in there?
   > 
   > ```groovy
   > Class.forName('org.springframework.security.core.SpringSecurityCoreVersion')?.version
   > ```
   
   @codeconsole I'm not sure we should do class loading for optional dependencies in the banner. You could add it yourself in your app:
   ```groovy
       static void main(String[] args) {
           new GrailsApp(Application).tap {
               banner = new GrailsBanner() {
                   @Override
                   Map<String, String> createBannerVersions(Environment environment) {
                       super.createBannerVersions(environment) +
                           ['Spring Security': Class.forName('org.springframework.security.core.SpringSecurityCoreVersion')?.version]
                   }
               }
           }.run()
       }
   ```


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3548546257

   > @codeconsole I'm not sure we should do class loading for optional dependencies in the banner. You could add it yourself in your app
   
   I agree for any other optional dependencies, but Spring Security is such a fundamental core dependency that it would be nice to display as a default.  You can just surround it with a ignored ClassNotFoundException and it is harmless.


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3539463366

   looks nice, but I wonder I wonder if it should also display when banner is off?  In all my apps, I have been using
   ```groovy
   log.info "${Metadata.current['info.app.name']}  v${Metadata.current['info.app.version']} (Java ${System.getProperty('java.version')} Groovy ${GroovySystem.getVersion()} Grails ${Metadata.current['info.app.grailsVersion']} Spring Boot ${SpringBootVersion.version} Spring ${SpringVersion.version})"
   ```
   because it is useful for troubleshooting to know what versions you are running.   I have banner off because I don't want to fill my logs with a banner (especially when I am running multiple instances).    
   
   Or have a separate setting to display it if banner is off?


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "sbglasius (via GitHub)" <gi...@apache.org>.
sbglasius commented on code in PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#discussion_r2533275350


##########
grails-core/src/main/groovy/grails/boot/GrailsBanner.groovy:
##########
@@ -0,0 +1,92 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.boot
+
+import groovy.transform.CompileStatic
+
+import org.springframework.boot.Banner
+import org.springframework.boot.SpringBootVersion
+import org.springframework.core.SpringVersion
+import org.springframework.core.env.Environment
+import org.springframework.core.io.ClassPathResource
+
+import grails.util.BuildSettings
+
+@CompileStatic
+class GrailsBanner implements Banner {
+
+    private static final int FALLBACK_BANNER_WIDTH = 80
+    private static final int VERSIONS_MARGIN = 4
+    private static final String VERSIONS_SEPARATOR = ' | '
+
+    private final String bannerFile
+
+    GrailsBanner(String bannerFile) {
+        this.bannerFile = bannerFile
+    }
+
+    @Override
+    void printBanner(Environment environment, Class<?> sourceClass, PrintStream out) {
+        def bannerResource = new ClassPathResource(bannerFile)
+        def asciiArt = bannerResource.exists() ? bannerResource.inputStream.text : ''
+        def bannerWidth = longestLineLength(asciiArt) ?: FALLBACK_BANNER_WIDTH
+        def versions = [
+                (environment.getProperty('info.app.name') ?: 'application'): environment.getProperty('info.app.version') ?: 'unknown',
+                'JVM': System.getProperty('java.vendor') + ' ' + System.getProperty('java.version'),
+                'Grails': BuildSettings.grailsVersion,
+                'Groovy': GroovySystem.version,
+                'Spring Boot': SpringBootVersion.version,
+                'Spring': SpringVersion.version
+        ]

Review Comment:
   Suggestion: If this was split out into a `protected` method, it would be possible for anyone to extend the `GrailsBanner` and the list, with information from CI/CD etc. 



-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty merged PR #15229:
URL: https://github.com/apache/grails-core/pull/15229


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "sbglasius (via GitHub)" <gi...@apache.org>.
sbglasius commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3534593941

   Something like this: https://github.com/apache/grails-core/pull/15230
   


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "sbglasius (via GitHub)" <gi...@apache.org>.
sbglasius commented on code in PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#discussion_r2533275350


##########
grails-core/src/main/groovy/grails/boot/GrailsBanner.groovy:
##########
@@ -0,0 +1,92 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.boot
+
+import groovy.transform.CompileStatic
+
+import org.springframework.boot.Banner
+import org.springframework.boot.SpringBootVersion
+import org.springframework.core.SpringVersion
+import org.springframework.core.env.Environment
+import org.springframework.core.io.ClassPathResource
+
+import grails.util.BuildSettings
+
+@CompileStatic
+class GrailsBanner implements Banner {
+
+    private static final int FALLBACK_BANNER_WIDTH = 80
+    private static final int VERSIONS_MARGIN = 4
+    private static final String VERSIONS_SEPARATOR = ' | '
+
+    private final String bannerFile
+
+    GrailsBanner(String bannerFile) {
+        this.bannerFile = bannerFile
+    }
+
+    @Override
+    void printBanner(Environment environment, Class<?> sourceClass, PrintStream out) {
+        def bannerResource = new ClassPathResource(bannerFile)
+        def asciiArt = bannerResource.exists() ? bannerResource.inputStream.text : ''
+        def bannerWidth = longestLineLength(asciiArt) ?: FALLBACK_BANNER_WIDTH
+        def versions = [
+                (environment.getProperty('info.app.name') ?: 'application'): environment.getProperty('info.app.version') ?: 'unknown',
+                'JVM': System.getProperty('java.vendor') + ' ' + System.getProperty('java.version'),
+                'Grails': BuildSettings.grailsVersion,
+                'Groovy': GroovySystem.version,
+                'Spring Boot': SpringBootVersion.version,
+                'Spring': SpringVersion.version
+        ]

Review Comment:
   Suggestion: If this was split out into a `protected` method, it would be possible for anyone to extend the list, with information from CI/CD etc. 



-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "matrei (via GitHub)" <gi...@apache.org>.
matrei commented on code in PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#discussion_r2533602943


##########
grails-core/src/main/groovy/grails/boot/GrailsBanner.groovy:
##########
@@ -0,0 +1,92 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.boot
+
+import groovy.transform.CompileStatic
+
+import org.springframework.boot.Banner
+import org.springframework.boot.SpringBootVersion
+import org.springframework.core.SpringVersion
+import org.springframework.core.env.Environment
+import org.springframework.core.io.ClassPathResource
+
+import grails.util.BuildSettings
+
+@CompileStatic
+class GrailsBanner implements Banner {
+
+    private static final int FALLBACK_BANNER_WIDTH = 80
+    private static final int VERSIONS_MARGIN = 4
+    private static final String VERSIONS_SEPARATOR = ' | '
+
+    private final String bannerFile
+
+    GrailsBanner(String bannerFile) {
+        this.bannerFile = bannerFile
+    }
+
+    @Override
+    void printBanner(Environment environment, Class<?> sourceClass, PrintStream out) {
+        def bannerResource = new ClassPathResource(bannerFile)
+        def asciiArt = bannerResource.exists() ? bannerResource.inputStream.text : ''
+        def bannerWidth = longestLineLength(asciiArt) ?: FALLBACK_BANNER_WIDTH
+        def versions = [
+                (environment.getProperty('info.app.name') ?: 'application'): environment.getProperty('info.app.version') ?: 'unknown',
+                'JVM': System.getProperty('java.vendor') + ' ' + System.getProperty('java.version'),
+                'Grails': BuildSettings.grailsVersion,
+                'Groovy': GroovySystem.version,
+                'Spring Boot': SpringBootVersion.version,
+                'Spring': SpringVersion.version
+        ]

Review Comment:
   @sbglasius See updated PR description.



-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "matrei (via GitHub)" <gi...@apache.org>.
matrei commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3552397350

   > I love the idea of this, but can we add documentation for this behavior? I think most of that documentation is already in this PR description - it just needs added to the docs
   
   @jdaugherty The functionality is now documented, thanks for reminding me!


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add versions to banner [grails-core]

Posted by "matrei (via GitHub)" <gi...@apache.org>.
matrei commented on PR #15229:
URL: https://github.com/apache/grails-core/pull/15229#issuecomment-3552412910

   @codeconsole and @sbglasius 
   I have added support for optional dependency versions via configuration:
   ```yaml
   grails:
     banner:
       versions:
         include:
           - spring-security
           - tomcat
           - jetty
           - undertow
   ```


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org