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

See documentation changes in this PR for configuration options.

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.
- 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?

@codeconsole
Copy link
Contributor

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

yes 😄

@codeconsole
Copy link
Contributor

codeconsole commented Nov 18, 2025

@matrei bonus points if we can get Spring Security in there?

Class.forName('org.springframework.security.core.SpringSecurityCoreVersion')?.version

@sbglasius sbglasius self-requested a review November 18, 2025 07:26
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.

Awesome!

@matrei
Copy link
Contributor Author

matrei commented Nov 18, 2025

bonus points if we can get Spring Security in there?

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:

    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()
    }

Copy link
Contributor

@jdaugherty jdaugherty left a comment

Choose a reason for hiding this comment

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

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

@codeconsole
Copy link
Contributor

codeconsole commented Nov 18, 2025

@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 an ignored ClassNotFoundException and it is harmless.

@sbglasius
Copy link
Contributor

sbglasius commented Nov 19, 2025

@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 implemented, 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 😀

@matrei
Copy link
Contributor Author

matrei commented Nov 19, 2025

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!

@matrei
Copy link
Contributor Author

matrei commented Nov 19, 2025

@codeconsole and @sbglasius
I have added support for optional dependency versions via configuration:

grails:
  banner:
    versions:
      include:
        - spring-security
        - tomcat
        - jetty
        - undertow

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.

Marvelous

@jdaugherty jdaugherty merged commit 28fb382 into 7.1.x Nov 19, 2025
61 of 62 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Apache Grails Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants