Skip to content

Commit

Permalink
Sam cli java21 runtime (aws#559)
Browse files Browse the repository at this point in the history
* Add java21 runtime

* Add test_data for java21 and update gh action to use java21

* Update tests/integration/testdata/buildcmd/Java/gradlew/21/gradle/wrapper/gradle-wrapper.properties

Co-authored-by: Wing Fung Lau <[email protected]>

* Update tests/integration/testdata/buildcmd/Java/maven/21/pom.xml

Co-authored-by: Wing Fung Lau <[email protected]>

* Update tests/integration/testdata/buildcmd/Java/maven/21/pom.xml

Co-authored-by: Wing Fung Lau <[email protected]>

* attempt to fix gradle build test failure

* attempt to fix gradle build test failure

* upgrade gradle wrapper

* upgrading gradle wrapper

---------

Co-authored-by: Haresh Nasit <[email protected]>
Co-authored-by: Haresh Nasit <[email protected]>
  • Loading branch information
3 people authored Oct 18, 2023
1 parent b5b3682 commit c1b15fb
Show file tree
Hide file tree
Showing 40 changed files with 1,031 additions and 388 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
java-version: '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 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 @@ -103,6 +103,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 @@ -199,6 +200,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),
}
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 @@ -29,6 +29,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
2 changes: 1 addition & 1 deletion samcli/lib/utils/preview_runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"""
from typing import Set

PREVIEW_RUNTIMES: Set[str] = set()
PREVIEW_RUNTIMES: Set[str] = {"java21"}
7 changes: 5 additions & 2 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 @@ -130,6 +131,7 @@ def get_local_lambda_images_location(mapping, runtime):
"dotnet6": "amazon/dotnet6-base",
"go1.x": "amazon/go1.x-base",
"go (provided.al2)": "amazon/go-provided.al2-base",
"java21": "amazon/java21-base",
"java17": "amazon/java17-base",
"java11": "amazon/java11-base",
"java8.al2": "amazon/java8.al2-base",
Expand All @@ -156,6 +158,7 @@ def get_local_lambda_images_location(mapping, runtime):
"java8.al2": "Java8",
"java11": "Java8",
"java17": "Java17",
"java21": "Java21",
"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 @@ -47,6 +47,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 @@ -882,6 +882,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 @@ -899,50 +909,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

0 comments on commit c1b15fb

Please sign in to comment.