Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that application.* banner variables require a packaged jar or the use of Boot's launcher #33489

Closed
maciejwalkowiak opened this issue Dec 8, 2022 · 7 comments
Labels
type: documentation A documentation update
Milestone

Comments

@maciejwalkowiak
Copy link
Contributor

maciejwalkowiak commented Dec 8, 2022

With a following custom banner.txt file in src/main/resources:

Custom Banner

${application.title}: ${application.version}

When application is built to a native image, printed banner has placeholders resolved to empty strings:

Custom Banner

: 

Where the expected output is:

Custom Banner

spring-native-banner-test: 0.0.1-SNAPSHOT
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 8, 2022
@mhalbritter
Copy link
Contributor

mhalbritter commented Dec 8, 2022

I can't reproduce this:

Custom Banner

the title: 1.0.0-SNAPSHOT

2022-12-08T10:16:53.797+01:00  INFO 131805 --- [           main] com.example.gh33489.Gh33489Application   : Starting AOT-processed Gh33489Application using Java 17.0.5 with PID 131805 (/home/moe/Downloads/issue-projects/gh-33489/build/native/nativeCompile/gh-33489 started by moe in /home/moe/Downloads/issue-projects/gh-33489)
2022-12-08T10:16:53.797+01:00  INFO 131805 --- [           main] com.example.gh33489.Gh33489Application   : No active profile set, falling back to 1 default profile: "default"
2022-12-08T10:16:53.802+01:00  INFO 131805 --- [           main] com.example.gh33489.Gh33489Application   : Started Gh33489Application in 0.016 seconds (process running for 0.025)

with application.properties containing:

application.title=the title
application.version=1.0.0-SNAPSHOT

Do you have a small sample application with which i can reproduce the problem?

@mhalbritter mhalbritter added the status: waiting-for-feedback We need additional information before we can continue label Dec 8, 2022
@maciejwalkowiak
Copy link
Contributor Author

With a regular executable JAR build there is no need to set these variables in application.properties. They are taken from somewhere else (perhaps manifest file?)

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 8, 2022
@mhalbritter
Copy link
Contributor

Ah yes, you are right. They are read from the MANIFEST.MF, which doesn't work in native image.

@mhalbritter mhalbritter added type: bug A general bug theme: aot An issue related to Ahead-of-time processing and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Dec 8, 2022
@mhalbritter mhalbritter added this to the 3.0.x milestone Dec 8, 2022
@mhalbritter mhalbritter changed the title Placeholders are not resolved in custom banner in Native build Placeholders from manifest are not resolved in custom banner in native image Dec 8, 2022
@mhalbritter mhalbritter self-assigned this Jan 10, 2023
@mhalbritter
Copy link
Contributor

mhalbritter commented Jan 10, 2023

Hm, unfortunately it isn't as easy as first thought. The entries which are used in the banner are written by the bootJar task:

tasks.named("bootJar") {
	manifest {
		attributes(
				'Implementation-Title': 'myapp',
				'Implementation-Version': '1.0.0-SNAPSHOT'
		)
	}
}

When compiling the native image, we don't use the JAR, we provide the classpath to native-image. Therefore there is no Manifest which contains these entries which we could just register resource hints for.

Even at AOT processing time, the banner looks wrong:

> Task :processAot
Custom Banner, running Spring Boot 3.0.1

: 

2023-01-10T14:19:40.236+01:00  INFO 55412 --- [           main] com.example.gh33489.Gh33489Application   : Starting Gh33489Application using Java 17.0.5 with PID 55412 (/home/moe/Downloads/issue-projects/gh-33489/build/classes/java/main started by moe in /home/moe/Downloads/issue-projects/gh-33489)
2023-01-10T14:19:40.239+01:00  INFO 55412 --- [           main] com.example.gh33489.Gh33489Application   : No active profile set, falling back to 1 default profile: "default"

because the manifest is not yet written.

@mhalbritter mhalbritter removed their assignment Jan 10, 2023
@wilkinsona
Copy link
Member

I suspect the same problem exists with bootRun as well. In other words, this may not be AOT-specific and may also be a problem in 2.x.

@mhalbritter
Copy link
Contributor

Yes, you're right Andy. gradle bootRun prints

Custom Banner, running Spring Boot 3.0.1

:

@mhalbritter mhalbritter modified the milestones: 3.0.x, 2.7.x Jan 10, 2023
@mhalbritter mhalbritter removed the theme: aot An issue related to Ahead-of-time processing label Jan 10, 2023
@mhalbritter mhalbritter changed the title Placeholders from manifest are not resolved in custom banner in native image Placeholders from manifest are not resolved when not running from JAR Jan 10, 2023
@philwebb philwebb changed the title Placeholders from manifest are not resolved when not running from JAR Placeholders for manifest entries in custom banner.txt files are not always resolved Jan 10, 2023
@wilkinsona
Copy link
Member

wilkinsona commented Oct 31, 2023

The docs already have a note about this for application.version. I think the best we can do is to expand that note to cover application.title as well.

@wilkinsona wilkinsona changed the title Placeholders for manifest entries in custom banner.txt files are not always resolved Document that application.* banner variables require a packaged jar or the use of Boot's launcher Oct 31, 2023
@wilkinsona wilkinsona added type: documentation A documentation update and removed type: bug A general bug labels Oct 31, 2023
@wilkinsona wilkinsona modified the milestones: 2.7.x, 2.7.18 Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

4 participants