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?

Comment From: garretwilson

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.

Comment From: wilkinsona

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.