-
Notifications
You must be signed in to change notification settings - Fork 90
docs: Adding Kotlin example. #1454
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
e66095e
Setting up Kotlin environment. Converting test to Kotlin.
ea0b496
Deploying via SAM successfully.
615a095
Added Kotlin example.
5199105
Removing unused Gradle build file.
37020f3
Merge branch 'main' into main
scottgerring 6386358
Adding SAM template so can be used as an existing project and Java ta…
19679da
Adding SAM template so can be used as an existing project
17c3a5e
Updating guidance to use SAM for build and deploy
1312c02
Restructuring separate Java and Kotlin examples.
18c7f48
Updating core examples readme to represent new structure for Java and…
d968f3c
Refactoring application code for efficiency, updating build to cover …
5ce71f7
Updating to fix trailing \n
35fbbac
Updating guidance to be more specific for examples
6ffa295
Merge branch 'main' into main
scottgerring d277c5c
Adopting new mechanism for specifying jvm target.
6c4646e
accommodating new project structure
6eecb90
Fixing link typo after refactoring
66a3dc2
Merge branch 'main' into main
scottgerring 1431899
Setting up Kotlin environment. Converting test to Kotlin.
3396766
Deploying via SAM successfully.
baa0e3f
Added Kotlin example.
16380a8
Removing unused Gradle build file.
3f3f4e8
Adding SAM template so can be used as an existing project and Java ta…
9d70b57
Adding SAM template so can be used as an existing project
bcff275
Updating guidance to use SAM for build and deploy
84935c9
Restructuring separate Java and Kotlin examples.
bf6da0d
Updating core examples readme to represent new structure for Java and…
f67f59a
Refactoring application code for efficiency, updating build to cover …
f7288d5
Updating to fix trailing \n
f03b01b
Updating guidance to be more specific for examples
e523554
Adopting new mechanism for specifying jvm target.
a71e263
accommodating new project structure
51fc239
Fixing link typo after refactoring
6cef711
Flattening structure back to original to make merging easier for v2
2444ba4
Merge remote-tracking branch 'origin/main'
c24ee6d
Adding build for Kotlin Gradle
de19b56
Adding build for Kotlin Gradle - Restructuring Java examples to v1 ap…
6e23b26
Correcting paths
480dd8b
Adding SNAPSHOT support and local capability for Maven. Testing using…
7a8dc16
Reviewed and updated against PR comments.
de08cbc
Merge branch 'main' into main
scottgerring bf843a7
Merging with Terraform additions from main branch
9a154dd
Un-commenting examples
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -1,92 +1,92 @@ | ||
@rem | ||
@rem Copyright 2015 the original author or authors. | ||
@rem | ||
@rem Licensed under the Apache License, Version 2.0 (the "License"); | ||
@rem you may not use this file except in compliance with the License. | ||
@rem You may obtain a copy of the License at | ||
@rem | ||
@rem https://www.apache.org/licenses/LICENSE-2.0 | ||
@rem | ||
@rem Unless required by applicable law or agreed to in writing, software | ||
@rem distributed under the License is distributed on an "AS IS" BASIS, | ||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
@rem See the License for the specific language governing permissions and | ||
@rem limitations under the License. | ||
@rem | ||
|
||
@if "%DEBUG%"=="" @echo off | ||
@rem ########################################################################## | ||
@rem | ||
@rem Gradle startup script for Windows | ||
@rem | ||
@rem ########################################################################## | ||
|
||
@rem Set local scope for the variables with windows NT shell | ||
if "%OS%"=="Windows_NT" setlocal | ||
|
||
set DIRNAME=%~dp0 | ||
if "%DIRNAME%"=="" set DIRNAME=. | ||
@rem This is normally unused | ||
set APP_BASE_NAME=%~n0 | ||
set APP_HOME=%DIRNAME% | ||
|
||
@rem Resolve any "." and ".." in APP_HOME to make it shorter. | ||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi | ||
|
||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" | ||
|
||
@rem Find java.exe | ||
if defined JAVA_HOME goto findJavaFromJavaHome | ||
|
||
set JAVA_EXE=java.exe | ||
%JAVA_EXE% -version >NUL 2>&1 | ||
if %ERRORLEVEL% equ 0 goto execute | ||
|
||
echo. | ||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
echo. | ||
echo Please set the JAVA_HOME variable in your environment to match the | ||
echo location of your Java installation. | ||
|
||
goto fail | ||
|
||
:findJavaFromJavaHome | ||
set JAVA_HOME=%JAVA_HOME:"=% | ||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe | ||
|
||
if exist "%JAVA_EXE%" goto execute | ||
|
||
echo. | ||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | ||
echo. | ||
echo Please set the JAVA_HOME variable in your environment to match the | ||
echo location of your Java installation. | ||
|
||
goto fail | ||
|
||
:execute | ||
@rem Setup the command line | ||
|
||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||
|
||
|
||
@rem Execute Gradle | ||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* | ||
|
||
:end | ||
@rem End local scope for the variables with windows NT shell | ||
if %ERRORLEVEL% equ 0 goto mainEnd | ||
|
||
:fail | ||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | ||
rem the _cmd.exe /c_ return code! | ||
set EXIT_CODE=%ERRORLEVEL% | ||
if %EXIT_CODE% equ 0 set EXIT_CODE=1 | ||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% | ||
exit /b %EXIT_CODE% | ||
|
||
:mainEnd | ||
if "%OS%"=="Windows_NT" endlocal | ||
|
||
:omega | ||
@rem | ||
@rem Copyright 2015 the original author or authors. | ||
@rem | ||
@rem Licensed under the Apache License, Version 2.0 (the "License"); | ||
@rem you may not use this file except in compliance with the License. | ||
@rem You may obtain a copy of the License at | ||
@rem | ||
@rem https://www.apache.org/licenses/LICENSE-2.0 | ||
@rem | ||
@rem Unless required by applicable law or agreed to in writing, software | ||
@rem distributed under the License is distributed on an "AS IS" BASIS, | ||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
@rem See the License for the specific language governing permissions and | ||
@rem limitations under the License. | ||
@rem | ||
|
||
@if "%DEBUG%"=="" @echo off | ||
@rem ########################################################################## | ||
@rem | ||
@rem Gradle startup script for Windows | ||
@rem | ||
@rem ########################################################################## | ||
|
||
@rem Set local scope for the variables with windows NT shell | ||
if "%OS%"=="Windows_NT" setlocal | ||
|
||
set DIRNAME=%~dp0 | ||
if "%DIRNAME%"=="" set DIRNAME=. | ||
@rem This is normally unused | ||
set APP_BASE_NAME=%~n0 | ||
set APP_HOME=%DIRNAME% | ||
|
||
@rem Resolve any "." and ".." in APP_HOME to make it shorter. | ||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi | ||
|
||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" | ||
|
||
@rem Find java.exe | ||
if defined JAVA_HOME goto findJavaFromJavaHome | ||
|
||
set JAVA_EXE=java.exe | ||
%JAVA_EXE% -version >NUL 2>&1 | ||
if %ERRORLEVEL% equ 0 goto execute | ||
|
||
echo. | ||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
echo. | ||
echo Please set the JAVA_HOME variable in your environment to match the | ||
echo location of your Java installation. | ||
|
||
goto fail | ||
|
||
:findJavaFromJavaHome | ||
set JAVA_HOME=%JAVA_HOME:"=% | ||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe | ||
|
||
if exist "%JAVA_EXE%" goto execute | ||
|
||
echo. | ||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | ||
echo. | ||
echo Please set the JAVA_HOME variable in your environment to match the | ||
echo location of your Java installation. | ||
|
||
goto fail | ||
|
||
:execute | ||
@rem Setup the command line | ||
|
||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||
|
||
|
||
@rem Execute Gradle | ||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* | ||
|
||
:end | ||
@rem End local scope for the variables with windows NT shell | ||
if %ERRORLEVEL% equ 0 goto mainEnd | ||
|
||
:fail | ||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | ||
rem the _cmd.exe /c_ return code! | ||
set EXIT_CODE=%ERRORLEVEL% | ||
if %EXIT_CODE% equ 0 set EXIT_CODE=1 | ||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% | ||
exit /b %EXIT_CODE% | ||
|
||
:mainEnd | ||
if "%OS%"=="Windows_NT" endlocal | ||
|
||
:omega |
This file contains hidden or 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,38 @@ | ||
# Powertools for AWS Lambda (Kotlin) - Core Utilities Example | ||
|
||
This project demonstrates the Lambda for Powertools Kotlin module deployed using [Serverless Application Model](https://aws.amazon.com/serverless/sam/) with | ||
[Gradle](https://gradle.org/) running the build. This example is configured for Java 1.8 only; in order to use a newer version, check out the Gradle | ||
configuration guide [in the main project README](../../../README.md). | ||
|
||
You can also use `sam init` to create a new Gradle-powered Powertools application - choose to use the **AWS Quick Start Templates**, | ||
and then **Hello World Example with Powertools for AWS Lambda**, **Java 17** runtime, and finally **gradle**. | ||
|
||
For general information on the deployed example itself, you can refer to the parent [README](../README.md) | ||
|
||
## Configuration | ||
SAM uses [template.yaml](template.yaml) to define the application's AWS resources. | ||
This file defines the Lambda function to be deployed as well as API Gateway for it. | ||
|
||
The build of the project is managed by Gradle, and configured in [build.gradle.kts](build.gradle.kts) | ||
. | ||
|
||
## Deploy the sample application | ||
To get started, you can use the included template with SAM to run the build and deploy to your AWS environment: | ||
|
||
```bash | ||
sam build && sam deploy --guided | ||
``` | ||
|
||
Once this is done to deploy the example, check out the instructions for getting started with SAM in | ||
[the examples directory](../../README.md) | ||
|
||
## Additional notes | ||
|
||
You can watch the trace information or log information using the SAM CLI: | ||
```bash | ||
# Tail the logs | ||
sam logs --tail $MY_STACK | ||
|
||
# Tail the traces | ||
sam traces --tail | ||
``` |
This file contains hidden or 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,39 @@ | ||
plugins { | ||
id("io.freefair.aspectj.post-compile-weaving") version "6.6.3" | ||
kotlin("jvm") version "1.9.10" | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("com.amazonaws:aws-lambda-java-core:1.2.2") | ||
implementation("com.fasterxml.jackson.core:jackson-annotations:2.13.2") | ||
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.2.2") | ||
implementation("com.amazonaws:aws-lambda-java-events:3.11.0") | ||
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2") | ||
aspect("software.amazon.lambda:powertools-tracing:1.18.0-SNAPSHOT") | ||
aspect("software.amazon.lambda:powertools-logging:1.18.0-SNAPSHOT") | ||
aspect("software.amazon.lambda:powertools-metrics:1.18.0-SNAPSHOT") | ||
testImplementation("junit:junit:4.13.2") | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") | ||
} | ||
|
||
tasks.compileKotlin { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
jasoniharris marked this conversation as resolved.
Show resolved
Hide resolved
jasoniharris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
tasks.compileTestKotlin { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
// If using JDK 11 or higher, use the following instead: | ||
//kotlin { | ||
// jvmToolchain(11) | ||
//} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.