Manual Deployment

You can deploy your function to AWS Lambda manually by building and uploading an executable JAR file. Various build plugins offer this capability.

Gradle Shadow plugin

The Gradle Shadow plugin provides a shadowJar task to generate a self-contained executable JAR file, which is suitable for AWS Lambda deployments.

Example build.gradle

  1. buildscript {
  2. repositories {
  3. maven { url "https://plugins.gradle.org/m2/" } (1)
  4. }
  5. dependencies {
  6. classpath "com.github.jengelman.gradle.plugins:shadow:2.0.4"
  7. ...
  8. }
  9. }
  10. apply plugin:"com.github.johnrengelman.shadow"
  11. shadowJar {
  12. mergeServiceFiles()
  13. }
1The Gradle Shadow plugin is hosted in the http://plugins.gradle.org repository

The executable JAR file can now be built using the shadowJar task.

  1. $ ./gradlew shadowJar

Maven Shade plugin

The Maven Shade plugin will generate an executable JAR file for Maven projects. For further details, consult the AWS Lambda Documentation.

Example pom.xml

  1. <project>
  2. <build>
  3. <plugins>
  4. <plugin>
  5. <groupId>org.apache.maven.plugins</groupId>
  6. <artifactId>maven-shade-plugin</artifactId>
  7. <version>3.1.0</version>
  8. <executions>
  9. <execution>
  10. <phase>package</phase>
  11. <goals>
  12. <goal>shade</goal>
  13. </goals>
  14. <configuration>
  15. <transformers>
  16. <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
  17. <mainClass>${exec.mainClass}</mainClass>
  18. </transformer>
  19. <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
  20. </transformers>
  21. </configuration>
  22. </execution>
  23. </executions>
  24. </plugin>
  25. </plugins>
  26. </build>
  27. </project>

The executable JAR file can now be built using the package phase.

  1. $ ./mvnw package