Skip to content

Commit

Permalink
Add example for Java build with Gradle (#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Souza authored and tj committed Jan 26, 2017
1 parent c8263bd commit c833d05
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _examples/java/functions/with-gradle/.apexignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!apex.jar
26 changes: 26 additions & 0 deletions _examples/java/functions/with-gradle/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apply plugin: 'java'

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile (
'com.amazonaws:aws-lambda-java-core:1.1.0',
)
}

task buildJar(type: Jar) {
archiveName = "apex.jar"
from compileJava
from processResources
into('lib') {
from configurations.runtime
}
}

build.dependsOn buildJar

9 changes: 9 additions & 0 deletions _examples/java/functions/with-gradle/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"description": "Java example function with existing build.gradle",
"handler": "lambda.Example::handler",
"runtime": "java",
"hooks": {
"build": "gradle build",
"clean": "gradle clean"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package lambda;

import com.amazonaws.services.lambda.runtime.Context;

public class Example {

public static class ExampleRequest {
String hello;

public String getHello() {
return hello;
}

public void setHello(String hello) {
this.hello = hello;
}

public ExampleRequest(String hello) {
this.hello = hello;
}

public ExampleRequest() {
}
}

public static class ExampleResponse {
String hello;

public String getHello() {
return hello;
}

public void setHello(String hello) {
this.hello = hello;
}

public ExampleResponse(String hello) {
this.hello = hello;
}

public ExampleResponse() {
}
}

public ExampleResponse handler(ExampleRequest event, Context context) {
return new ExampleResponse(event.getHello());
}
}

0 comments on commit c833d05

Please sign in to comment.