Skip to content

Add Gradle 9.0 support #768

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion aws_lambda_builders/workflows/java_gradle/gradle.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def build(self, source_dir, build_file, cache_dir=None, init_script_path=None, p
if not self.os_utils.exists(build_file):
raise BuildFileNotFoundError(build_file)

args = ["build", "--build-file", build_file]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random thoughts here.

I see that now the build_file parameter is not used anywhere in the method anymore, so maybe we could remove it from the function signature: build(self, source_dir, cache_dir=None, init_script_path=None, properties=None)

If we do that, we would probably want to update the rest of the places where this is used, like the actions file and remove it from the JavaGradleBuildAction fields, and then remove it from the workflow file where this is called.

This would potentially break users if they're using these classes directly instead of using the LambdaBuilder object that SAM CLI uses, but I guess if that's the case, they can "not upgrade to the new lambda-builders version until they remove this extra parameter from their code".

Nah, but I think at the end of the day, it's okay to leave it like this. Maybe it could be better to add a comment here just mentioning that we're not using the build_file parameter because Gradle doesn't support it anymore, but outside of that, I think we're okay.

args = ["build"]
if cache_dir is not None:
args.extend(["--project-cache-dir", cache_dir])
if properties is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def assertExpectedBuildDir(p) {
}

def createArtifactDir(project) {
def distsDir = project.buildDir.toPath().resolve(project.distsDirName).resolve('lambda-build')
// In Gradle 9, distsDirName was removed. Use 'distributions' as the default directory name
def distsDir = project.buildDir.toPath().resolve('distributions').resolve('lambda-build')
return makeDirs(distsDir)
}

Expand Down
8 changes: 3 additions & 5 deletions tests/unit/workflows/java_gradle/test_gradle.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_build_no_init_script(self):
gradle = SubprocessGradle(gradle_binary=self.gradle_binary, os_utils=self.os_utils)
gradle.build(self.source_dir, self.manifest_path)
self.os_utils.popen.assert_called_with(
[self.gradle_path, "build", "--build-file", self.manifest_path],
[self.gradle_path, "build"],
cwd=self.source_dir,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
Expand All @@ -70,7 +70,7 @@ def test_gradlew_path_is_dummy_uses_gradle_binary(self):
gradle = SubprocessGradle(gradle_binary=self.gradle_binary, os_utils=self.os_utils)
gradle.build(self.source_dir, self.manifest_path)
self.os_utils.popen.assert_called_with(
[self.gradle_path, "build", "--build-file", self.manifest_path],
[self.gradle_path, "build"],
cwd=self.source_dir,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
Expand All @@ -80,7 +80,7 @@ def test_build_with_init_script(self):
gradle = SubprocessGradle(gradle_binary=self.gradle_binary, os_utils=self.os_utils)
gradle.build(self.source_dir, self.manifest_path, init_script_path=self.init_script)
self.os_utils.popen.assert_called_with(
[self.gradle_path, "build", "--build-file", self.manifest_path, "--init-script", self.init_script],
[self.gradle_path, "build", "--init-script", self.init_script],
cwd=self.source_dir,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
Expand All @@ -101,8 +101,6 @@ def test_includes_build_properties_in_command(self):
[
self.gradle_path,
"build",
"--build-file",
self.manifest_path,
"-Dfoo=bar",
"--init-script",
self.init_script,
Expand Down
Loading