Skip to content
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

Feat java21 runtime #6261

Merged
merged 17 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
java-version: |
8
11
17
21
# Install and configure Rust & Cargo Lambda
- name: Install and configure Rust & Cargo Lambda
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/build/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
1. Python 3.7, 3.8, 3.9, 3.10, 3.11 using PIP\n
2. Nodejs 20.x, 18.x, 16.x, 14.x, 12.x using NPM\n
3. Ruby 2.7, 3.2 using Bundler\n
4. Java 8, Java 11, Java 17 using Gradle and Maven\n
4. Java 8, Java 11, Java 17, Java 21 using Gradle and Maven\n
5. Dotnet6 using Dotnet CLI (without --use-container)\n
6. Go 1.x using Go Modules (without --use-container)\n
"""
Expand Down
9 changes: 9 additions & 0 deletions samcli/lib/build/workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def get_layer_subfolder(build_workflow: str) -> str:
"java11": "java",
"java8.al2": "java",
"java17": "java",
"java21": "java",
"dotnet6": "dotnet",
# User is responsible for creating subfolder in these workflows
"makefile": "",
Expand Down Expand Up @@ -201,6 +202,14 @@ def get_workflow_config(
JAVA_MAVEN_CONFIG,
]
),
"java21": ManifestWorkflowSelector(
[
# Gradle builder needs custom executable paths to find `gradlew` binary
JAVA_GRADLE_CONFIG._replace(executable_search_paths=[code_dir, project_dir]),
JAVA_KOTLIN_GRADLE_CONFIG._replace(executable_search_paths=[code_dir, project_dir]),
JAVA_MAVEN_CONFIG,
]
),
"provided": BasicWorkflowSelector(PROVIDED_MAKE_CONFIG),
"provided.al2": BasicWorkflowSelector(PROVIDED_MAKE_CONFIG),
"provided.al2023": BasicWorkflowSelector(PROVIDED_MAKE_CONFIG),
Expand Down
1 change: 1 addition & 0 deletions samcli/lib/utils/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"java8.al2": [ARM64, X86_64],
"java11": [ARM64, X86_64],
"java17": [ARM64, X86_64],
"java21": [ARM64, X86_64],
"go1.x": [X86_64],
"dotnet6": [ARM64, X86_64],
"provided": [X86_64],
Expand Down
10 changes: 7 additions & 3 deletions samcli/local/common/runtime_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
],
"java": [
{
"runtimes": ["java11", "java8", "java8.al2", "java17"],
"runtimes": ["java11", "java8", "java8.al2", "java17", "java21"],
"dependency_manager": "maven",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-java-maven"),
"build": True,
},
{
"runtimes": ["java11", "java8", "java8.al2", "java17"],
"runtimes": ["java11", "java8", "java8.al2", "java17", "java21"],
"dependency_manager": "gradle",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-java-gradle"),
"build": True,
Expand Down Expand Up @@ -102,6 +102,7 @@ def get_local_lambda_images_location(mapping, runtime):
"dotnet6",
"go1.x",
# java runtimes in descending order
"java21",
"java17",
"java11",
"java8.al2",
Expand Down Expand Up @@ -133,6 +134,7 @@ def get_local_lambda_images_location(mapping, runtime):
"go1.x": "amazon/go1.x-base",
"go (provided.al2)": "amazon/go-provided.al2-base",
"go (provided.al2023)": "amazon/go-provided.al2023-base",
"java21": "amazon/java21-base",
"java17": "amazon/java17-base",
"java11": "amazon/java11-base",
"java8.al2": "amazon/java8.al2-base",
Expand All @@ -155,11 +157,13 @@ def get_local_lambda_images_location(mapping, runtime):

# Schemas Code lang is a MINIMUM supported version
# - this is why later Lambda runtimes can be mapped to earlier Schemas Code Languages
# event schema registry supports only java8, python3.6, dotnet6, and Go1 for code binding
SAM_RUNTIME_TO_SCHEMAS_CODE_LANG_MAPPING = {
"java8": "Java8",
"java8.al2": "Java8",
"java11": "Java8",
"java17": "Java17",
"java17": "Java8",
"java21": "Java8",
"python3.7": "Python36",
"python3.8": "Python36",
"python3.9": "Python36",
Expand Down
10 changes: 10 additions & 0 deletions samcli/local/docker/lambda_debug_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ def get_debug_settings(debug_port, debug_args_list, _container_env_vars, runtime
**_container_env_vars,
},
),
Runtime.java21.value: lambda: DebugSettings(
entry,
container_env_vars={
"_JAVA_OPTIONS": "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,"
f"address=*:{debug_port} -XX:MaxHeapSize=2834432k -XX:+UseSerialGC "
"-XX:+TieredCompilation -XX:TieredStopAtLevel=1 "
"-Djava.net.preferIPv4Stack=true" + " ".join(debug_args_list),
**_container_env_vars,
},
),
Runtime.dotnet6.value: lambda: DebugSettings(
entry + ["/var/runtime/bootstrap"] + debug_args_list,
container_env_vars={"_AWS_LAMBDA_DOTNET_DEBUGGING": "1", **_container_env_vars},
Expand Down
1 change: 1 addition & 0 deletions samcli/local/docker/lambda_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Runtime(Enum):
java8al2 = "java8.al2"
java11 = "java11"
java17 = "java17"
java21 = "java21"
go1x = "go1.x"
dotnet6 = "dotnet6"
provided = "provided"
Expand Down
102 changes: 67 additions & 35 deletions tests/integration/buildcmd/test_build_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,16 @@ class TestBuildCommand_Java(BuildIntegJavaBase):
EXPECTED_GRADLE_DEPENDENCIES,
),
("java17", "17", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
("java21", "21", USING_GRADLE_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java21", "21", USING_GRADLEW_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
(
"java21",
"21",
USING_GRADLE_KOTLIN_PATH,
EXPECTED_FILES_PROJECT_MANIFEST_GRADLE,
EXPECTED_GRADLE_DEPENDENCIES,
),
("java21", "21", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
]
)
@skipIf(SKIP_DOCKER_TESTS or SKIP_DOCKER_BUILD, SKIP_DOCKER_MESSAGE)
Expand All @@ -905,50 +915,72 @@ def test_building_java_in_container(

@parameterized.expand(
[
("java8", USING_GRADLE_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java8", USING_GRADLEW_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java8", USING_GRADLE_KOTLIN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java8", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
("java8.al2", USING_GRADLE_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java8.al2", USING_GRADLEW_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java8", "8", USING_GRADLE_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java8", "8", USING_GRADLEW_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
(
"java8",
"8",
USING_GRADLE_KOTLIN_PATH,
EXPECTED_FILES_PROJECT_MANIFEST_GRADLE,
EXPECTED_GRADLE_DEPENDENCIES,
),
("java8", "8", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
("java8.al2", "8", USING_GRADLE_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
(
"java8.al2",
"8",
USING_GRADLEW_PATH,
EXPECTED_FILES_PROJECT_MANIFEST_GRADLE,
EXPECTED_GRADLE_DEPENDENCIES,
),
(
"java8.al2",
"8",
USING_GRADLE_KOTLIN_PATH,
EXPECTED_FILES_PROJECT_MANIFEST_GRADLE,
EXPECTED_GRADLE_DEPENDENCIES,
),
("java8.al2", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
]
)
def test_building_java8_in_process(self, runtime, code_path, expected_files, expected_dependencies):
self._test_with_building_java(
runtime, os.path.join(code_path, "8"), expected_files, expected_dependencies, False, self.test_data_path
)

@parameterized.expand(
[
("java11", USING_GRADLE_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java11", USING_GRADLEW_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java11", USING_GRADLE_KOTLIN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java11", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
]
)
def test_building_java11_in_process(self, runtime, code_path, expected_files, expected_dependencies):
self._test_with_building_java(
runtime, os.path.join(code_path, "11"), expected_files, expected_dependencies, False, self.test_data_path
)

@parameterized.expand(
[
("java17", USING_GRADLE_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java17", USING_GRADLEW_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java17", USING_GRADLE_KOTLIN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java17", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
("java8.al2", "8", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
("java11", "11", USING_GRADLE_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java11", "11", USING_GRADLEW_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
(
"java11",
"11",
USING_GRADLE_KOTLIN_PATH,
EXPECTED_FILES_PROJECT_MANIFEST_GRADLE,
EXPECTED_GRADLE_DEPENDENCIES,
),
("java11", "11", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
("java17", "17", USING_GRADLE_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java17", "17", USING_GRADLEW_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
(
"java17",
"17",
USING_GRADLE_KOTLIN_PATH,
EXPECTED_FILES_PROJECT_MANIFEST_GRADLE,
EXPECTED_GRADLE_DEPENDENCIES,
),
("java17", "17", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
("java21", "21", USING_GRADLE_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
("java21", "21", USING_GRADLEW_PATH, EXPECTED_FILES_PROJECT_MANIFEST_GRADLE, EXPECTED_GRADLE_DEPENDENCIES),
(
"java21",
"21",
USING_GRADLE_KOTLIN_PATH,
EXPECTED_FILES_PROJECT_MANIFEST_GRADLE,
EXPECTED_GRADLE_DEPENDENCIES,
),
("java21", "21", USING_MAVEN_PATH, EXPECTED_FILES_PROJECT_MANIFEST_MAVEN, EXPECTED_MAVEN_DEPENDENCIES),
]
)
def test_building_java17_in_process(self, runtime, code_path, expected_files, expected_dependencies):
def test_building_java_in_process(self, runtime, runtime_version, code_path, expected_files, expected_dependencies):
self._test_with_building_java(
runtime, os.path.join(code_path, "17"), expected_files, expected_dependencies, False, self.test_data_path
runtime,
os.path.join(code_path, runtime_version),
expected_files,
expected_dependencies,
False,
self.test_data_path,
)


Expand Down
Loading
Loading