Skip to content

Conversation

@matrei
Copy link
Contributor

@matrei matrei commented Nov 14, 2025

Will by default output versions below banner like:

    >                                                                            <
    >                            ____           _ _                              <
    >                           / ___|_ __ __ _(_) |___                          <
    >                          | |  _| '__/ _` | | / __|                         <
    >                          | |_| | | | (_| | | \__ \                         <
    >                           \____|_|  \__,_|_|_|___/                         <
    >                          https://grails.apache.org/                        <
    >                                                                            <
            grails-test-examples-async-events-pubsub-demo: 7.1.0-SNAPSHOT         
           JVM: BellSoft 17.0.17 | Grails: 7.1.0-SNAPSHOT | Groovy: 4.0.29        
                         Spring Boot: 3.5.7 | Spring: 6.2.12

Behavior can be overridden:

import org.springframework.core.env.Environment

import grails.boot.GrailsApp
import grails.boot.GrailsBanner
import grails.boot.config.GrailsAutoConfiguration

class Application extends GrailsAutoConfiguration {
	
    static void main(String[] args) {
        new GrailsApp(Application).tap {
            banner = new GrailsBanner() {

                @Override
                String createBannerArt(Environment environment) {
                    'HELLO WORLD'
                }

                @Override
                Map<String, String> createBannerVersions(Environment environment) {
                    if (System.getenv('CI')) {
                        return super.createBannerVersions(environment) + ['my-custom-info': 'Hello in CI']
                    }
                    return super.createBannerVersions(environment)
                }

                @Override
                boolean shouldDisplayArt(Environment environment) {
                    false
                }

                @Override
                boolean shouldDisplayVersions(Environment environment) {
                    true
                }

            }
        }.run()
    }
}

and the individual parts can be disabled with config properties:

grails:
  banner:
    display:
      art: false
      versions: true

Copy link
Contributor

@sbglasius sbglasius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a great idea 😄

@sbglasius
Copy link
Contributor

sbglasius commented Nov 14, 2025

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

To answer myself: System.getProperty('java.vendor')

@sbglasius
Copy link
Contributor

Something like this: #15230

@matrei matrei moved this to In Progress in Apache Grails Nov 15, 2025
@matrei matrei added this to the grails:7.1.0 milestone Nov 15, 2025
@codeconsole
Copy link
Contributor

looks nice, but I wonder I wonder if it should also display when banner is off? In all my apps, I have been using

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?

No need to store the versions or use resolvers.
They are only used in the `printBanner` method.
Comment on lines 49 to 56
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
]
Copy link
Contributor

@sbglasius sbglasius Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbglasius See updated PR description.

- Allow overriding behavior
- Add conditional output of art and versions
@matrei
Copy link
Contributor Author

matrei commented Nov 17, 2025

looks nice, but I wonder I wonder if it should also display when banner is off? In all my apps, I have been using

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants