aws / aws-lambda-builders

Python library to compile, build & package AWS Lambda functions for several runtimes & framework
Apache License 2.0
337 stars 140 forks source link

Bug: JavaGradleWorkflow not respecting gradlew with --use-container #641

Closed wiwa5606 closed 5 months ago

wiwa5606 commented 5 months ago

Description:

SAM does not download/use the Gradle wrapper when building Gradle function

Steps to reproduce:

We are passing credentials through an embedded gradle.properties file in the build image that we are using. Our CodeURI was set to IAPIHealthCheckServiceFn. The project file structure is as follows, attempting to replicate this:

IAPIHealthCheckServiceFn
.
├── IAPIHealthCheckServiceFn
│   ├── build.gradle
│   ├── gradle
│   │   └── wrapper
│   │       ├── gradle-wrapper.jar
│   │       └── gradle-wrapper.properties
│   ├── gradle.properties
│   ├── gradlew
│   ├── gradlew.bat
│   ├── settings.gradle
│   └── src
├── README.md
├── dev_template.yaml
├── int_template.yaml
├── scr-input.sh
└── sonar-project.properties

The structure for Project A here yield worse results, the build process fails to find the IAPIHealthCheckServiceFn folder. Note CodeURI was updated to . in this case:

.
├── README.md
├── build.gradle
├── dev_template.yaml
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── int_template.yaml
├── scr-input.sh
├── settings.gradle
├── sonar-project.properties
└── src

Observed result:

When we execute sam build, we see that SAM is using the Gradle embedded in the docker image, (6.2.2), instead of the version configured in gradle-wrapper.properties, (8.2). image

Expected result:

sam build should use gradlew and use gradle version 8.2

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

  1. OS: Linux
  2. If using SAM CLI, sam --version: SAM CLI, version 1.84.0
  3. AWS region: us-west-2
mildaniel commented 5 months ago

Hey @wiwa5606, can you try updating to the latest version of SAM CLI and seeing if the issue still exists?

wiwa5606 commented 5 months ago

Hey there, same behavior on 1.116.0

mildaniel commented 5 months ago

@wiwa5606, are you able to provide a minimal app with which you're seeing this issue? I've tried to reproduce starting from a hello-world Java gradle template, with various version of Java and gradle and haven't had any luck.

wiwa5606 commented 5 months ago

heya, we can close this issue. Our gradlew file did not have the executable bit set