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

Option for Spring Boot Maven Plugin to place classes in root of JAR, and libraries under lib directory #36101

Closed
garretwilson opened this issue Jun 27, 2023 · 2 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@garretwilson
Copy link

garretwilson commented Jun 27, 2023

The Spring Boot Maven Plugin does an awesome job of zipping up dependency JARs and classes in the current project. However the location it places them needs to be tweaked for certain platforms, specifically AWS Lambda.

This is expressly not a duplicate of #6626. As noted in that ticket:

That's not the goal of this issue. The goal of this issue is to make it easier to package additional new content in the root of the jar, not to copy the contents of BOOT-INF/classes into the root of the jar.

This ticket is in fact 1) to move the content of BOOT-INF/classes into the root of the JAR, and 2) move the BOOT-INF/lib directory itself to the root of the JAR.

I'm using the Spring Boot Maven Plugin with Maven 3.9.1 and Java 17 on Windows 10. If I use <layout>ZIP</layout> I get a layout like this:

  • BOOT-INF/classes/
  • BOOT-INF/classes/com/
  • BOOT-INF/classes/com/example/
  • BOOT-INF/classes/com/example/Foo.class
  • BOOT-INF/lib/
  • BOOT-INF/lib/foo.jar
  • BOOT-INF/lib/bar.jar

However in order to deploy a ZIP file to AWS Lambda, we supposedly need a layout something like this (although the layout AWS Lambda requires apparently isn't documented):

  • com/
  • com/example/
  • com/example/Foo.class
  • lib/
  • lib/foo.jar
  • lib/bar.jar

Most of the AWS documentation such as Deploy Java Lambda functions with .zip or JAR file archives simply says to use the Maven Shade Plugin, which is a real mess (forcing the developer to deal with irrelevant clashing text files and the like). Plus it breaks multirelease JARS by forcing multirelease data into the main JAR which AWS Lambda doesn't support.

The output of the Spring Boot Maven Plugin is much nicer—it just needs to be tweaked. Can we an an option to simply relocate the contents of those two subdirectories to a different location?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 27, 2023
@garretwilson
Copy link
Author

Another option is to use the Maven Assembly Plugin for this, but it requires a complicated, external assembly descriptor XML file which can't currently be inherited from a parent POM without elaborate workarounds.

@wilkinsona
Copy link
Member

Thanks for the suggestion, but I don't think this is something that we'd want to provide out of the box. You can, however, plug it into Boot's repackaging by implementing LayoutFactory. There's an example of the pom.xml configuration that's required in the plugin's reference docs.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2023
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

3 participants