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

A fat jar built with Gradle moves META-INF beneath BOOT-INF/classes while Maven leaves it at the jar's root #28562

Closed
wilkinsona opened this issue Nov 8, 2021 · 2 comments
Labels
type: bug A general bug
Milestone

Comments

@wilkinsona
Copy link
Member

wilkinsona commented Nov 8, 2021

With a few exceptions, the Maven repackaging leaves META-INF at the root of the jar. With Gradle, everything gets moved beneath BOOT-INF/classes.

@wilkinsona wilkinsona added type: bug A general bug for: team-meeting An issue we'd like to discuss as a team to make progress labels Nov 8, 2021
@wilkinsona wilkinsona added this to the 2.4.x milestone Nov 8, 2021
@nrheckman
Copy link

nrheckman commented Nov 8, 2021

I discovered the difference when attempting to build container images for use with Dataflow. The labels it uses to fill in the configuration weren't present when built via gradle but are when built via maven.

Some steps to reproduce the issue:

The expected behavior when using Maven can be seen via the following steps:

curl -G https://start.spring.io/starter.tgz -d dependencies=webflux -d type=maven-project -d baseDir=demo-maven | tar -xzvf -
cd demo-maven
mkdir src/main/resources/META-INF
echo "configuration-properties.names=server.port" > src/main/resources/META-INF/dataflow-configuration-metadata.properties
./mvnw spring-boot:build-image
docker inspect demo:0.0.1-SNAPSHOT |grep "org.springframework.boot.spring-configuration-metadata.json"

While the following shows the resources in the wrong location, thus not getting recognized for label generation:

curl -G https://start.spring.io/starter.tgz -d dependencies=webflux -d type=gradle-project -d baseDir=demo-gradle | tar -xzvf -
cd demo-gradle
mkdir src/main/resources/META-INF
echo "configuration-properties.names=server.port" > src/main/resources/META-INF/dataflow-configuration-metadata.properties
./gradlew bootBuildImage
docker inspect demo:0.0.1-SNAPSHOT |grep "org.springframework.boot.spring-configuration-metadata.json"

@wilkinsona
Copy link
Member Author

Thanks, @nrheckman.

The problem can also be reproduced using ./mvnw package and ./gradlew bootJar and then examining the contents of the resultant jars.

@philwebb philwebb removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Nov 10, 2021
@wilkinsona wilkinsona modified the milestones: 2.4.x, 2.5.x Nov 15, 2021
@wilkinsona wilkinsona modified the milestones: 2.5.x, 2.5.10 Feb 11, 2022
wilkinsona added a commit that referenced this issue Mar 2, 2022
The changes for gh-28562 attempted to align the Gradle plugin's
handling of META-INF with the Maven plugin's behavior. Unfortunately,
they want too far, applying the handling to both jar and war files
when the Maven plugin only applies it to jar files.

This commit reworks the changes so that they only apply to jar files.

Closes gh-30026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants