Skip to content

Gradle: Set java target level in cookiecutter and docs #702

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

Closed
michaelbrewer opened this issue Jan 10, 2022 · 2 comments · Fixed by #703
Closed

Gradle: Set java target level in cookiecutter and docs #702

michaelbrewer opened this issue Jan 10, 2022 · 2 comments · Fixed by #703
Labels
bug Something isn't working

Comments

@michaelbrewer
Copy link
Contributor

michaelbrewer commented Jan 10, 2022

What were you trying to accomplish?

Building the gradle project using jdk 17

Expected Behavior

Project should compile with target level of java 11 or java 1.8

Current Behavior

Sam template example fails

Running JavaGradleWorkflow:GradleBuild

Build Failed
Error: JavaGradleWorkflow:GradleBuild - Gradle Failed: [error] target level should be in '1.1'...'1.8','9'...'16' (or '5.0'..'16.0') or cldc1.1: 17

Possible Solution

Update gradle example

plugins{
    id 'java'
    id 'io.freefair.aspectj.post-compile-weaving' version '6.3.0'
}

repositories {
    mavenCentral()
}

dependencies {
    aspect 'software.amazon.lambda:powertools-logging:1.10.2'
    aspect 'software.amazon.lambda:powertools-tracing:1.10.2'
    aspect 'software.amazon.lambda:powertools-metrics:1.10.2'

    implementation 'com.amazonaws:aws-lambda-java-core:1.2.1'
    implementation 'com.amazonaws:aws-lambda-java-events:3.11.0'

    implementation 'org.apache.logging.log4j:log4j-api:2.17.1'
    implementation 'org.apache.logging.log4j:log4j-core:2.17.1'

    testImplementation 'junit:junit:4.13.2'
}

sourceCompatibility = 11
targetCompatibility = 11

Steps to Reproduce (for bugs)

  1. sam init --location gh:aws-samples/cookiecutter-aws-sam-powertools-java
  2. Select gradle and java11 (with java 17 installed locally)
  3. run sam build

Environment

  • Powertools version used: 1.10.2
  • Packaging format (Layers, Maven/Gradle): Gradle
  • AWS Lambda function runtime: Java 11 (or Java 1.8)
@michaelbrewer michaelbrewer added the bug Something isn't working label Jan 10, 2022
michaelbrewer added a commit to michaelbrewer/aws-lambda-powertools-java that referenced this issue Jan 10, 2022
Changes:
- Bump gradle version to 7.3.3
- Use `io.freefair.aspectj.post-compile-weaving` in example project
- Specify java 11 for sourceCompatibility, targetCompatibility
- Bump junit version to 4.13.2

closes aws-powertools#702
pankajagrawal16 pushed a commit that referenced this issue Jan 10, 2022
* fix(gradle): Fix gradle example and docs to work with java 12+

Changes:
- Bump gradle version to 7.3.3
- Use `io.freefair.aspectj.post-compile-weaving` in example project
- Specify java 11 for sourceCompatibility, targetCompatibility
- Bump junit version to 4.13.2

closes #702

* fix: no need to include implementation
@pankajagrawal16
Copy link
Contributor

Thanks for spotting and fixing the docs and config @michaelbrewer

@michaelbrewer
Copy link
Contributor Author

hopefully java 17 runtime is coming out soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants