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

Bug: sam build can't check the JVM version on gradle >= v8.9 #682

Open
jeffryang24 opened this issue Sep 5, 2024 · 2 comments · May be fixed by #683
Open

Bug: sam build can't check the JVM version on gradle >= v8.9 #682

jeffryang24 opened this issue Sep 5, 2024 · 2 comments · May be fixed by #683

Comments

@jeffryang24
Copy link

jeffryang24 commented Sep 5, 2024

Description:

Previously, sam build does not show this warning message when building using Gradle, but somehow this message appears in the new Gradle version.

failed to return a version string using the '-v' option. The workflow is unable to check that the version of the JVM used is compatible with AWS Lambda.

Steps to reproduce:

  1. Update the project gradle version to >= v8.9 (8.9 or 8.10).
  2. Run sam build on existing SAM application project.

Observed result:

Got above error message while the build process is successfully executed.

Expected result:

Don't show above error message since the JVM version should be available from gradlew -v command.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

After testing with older Gradle version (below v8.8), found out the gradle output for JVM has different label.

  • Gradle < v8.9 is using JVM label,
  • while Gradle >= v8.9 is using Launcher JVM or Daemon JVM label.

Gradle < v8.9

Use gradle v8.8 as example, current sam-cli integration test is using v8.4.

❯ ./gradlew --version                   

------------------------------------------------------------
Gradle 8.8
------------------------------------------------------------

Build time:   2024-05-31 21:46:56 UTC
Revision:     4bd1b3d3fc3f31db5a26eecb416a165b8cc36082

Kotlin:       1.9.22
Groovy:       3.0.21
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          21.0.4 (Amazon.com Inc. 21.0.4+7-LTS)
OS:           Mac OS X 14.6.1 aarch64

Gradle >= v8.9

Use gradle v8.9 as example.

❯ ./gradlew -v                          

------------------------------------------------------------
Gradle 8.9
------------------------------------------------------------

Build time:    2024-07-11 14:37:41 UTC
Revision:      d536ef36a19186ccc596d8817123e5445f30fef8

Kotlin:        1.9.23
Groovy:        3.0.21
Ant:           Apache Ant(TM) version 1.10.13 compiled on January 4 2023
Launcher JVM:  21.0.4 (Amazon.com Inc. 21.0.4+7-LTS)
Daemon JVM:    /Users/jeffry.angtoni/.sdkman/candidates/java/21.0.4-amzn (no JDK specified, using current Java home)
OS:            Mac OS X 14.6.1 aarch64

Root Cause

Probably, we need to update the startswith validation from this line,

to support previous (< v8.9) and newest gradle version (>= v8.9).

  1. OS: MacOS 14.6.1
  2. sam --version: 1.123.0
  3. AWS region: ap-southeast-1
# Paste the output of `sam --info` here
❯ sam --info --debug
{
  "version": "1.123.0",
  "system": {
    "python": "3.12.5",
    "os": "macOS-14.6.1-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "26.1.3",
    "aws_cdk": "Not available",
    "terraform": "1.7.5"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Add --debug flag to command you are running

@jeffryang24 jeffryang24 added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Sep 5, 2024
@jeffryang24
Copy link
Author

Forwarded from aws/aws-sam-cli#7446.

@hnnasit
Copy link
Contributor

hnnasit commented Sep 12, 2024

Hi @jeffryang24, thanks for reporting the bug and opening a PR to fix it.

@hnnasit hnnasit added type/bug area/workflow/java_gradle and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants