forked from imjerrybao/apex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for Java build with Gradle (#658)
- Loading branch information
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!apex.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
_examples/java/functions/with-gradle/src/main/java/lambda/Example.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |