Skip to content

Commit 6cd7ba8

Browse files
committed
Add Gradle 9.0 support by removing deprecated --build-file argument and distsDirName property
- Remove --build-file argument from gradle.py as it was deprecated in Gradle 8 and removed in Gradle 9 - Update lambda-build-init.gradle to use 'distributions' instead of deprecated distsDirName property - Update all related unit tests to reflect the command line changes - All unit and integration tests now pass with Gradle 9.0 Fixes: Unknown command-line option '--build-file' error when using Gradle 9.0
1 parent 3e531b3 commit 6cd7ba8

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

aws_lambda_builders/workflows/java_gradle/gradle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def build(self, source_dir, build_file, cache_dir=None, init_script_path=None, p
3333
if not self.os_utils.exists(build_file):
3434
raise BuildFileNotFoundError(build_file)
3535

36+
## Note: --build_file parameter is not supported anymore, but kept for backward compatibility
3637
args = ["build", "--build-file", build_file]
3738
if cache_dir is not None:
3839
args.extend(["--project-cache-dir", cache_dir])

aws_lambda_builders/workflows/java_gradle/resources/lambda-build-init.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def assertExpectedBuildDir(p) {
5454
}
5555

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

tests/unit/workflows/java_gradle/test_gradle.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_build_no_init_script(self):
6060
gradle = SubprocessGradle(gradle_binary=self.gradle_binary, os_utils=self.os_utils)
6161
gradle.build(self.source_dir, self.manifest_path)
6262
self.os_utils.popen.assert_called_with(
63-
[self.gradle_path, "build", "--build-file", self.manifest_path],
63+
[self.gradle_path, "build"],
6464
cwd=self.source_dir,
6565
stderr=subprocess.PIPE,
6666
stdout=subprocess.PIPE,
@@ -70,7 +70,7 @@ def test_gradlew_path_is_dummy_uses_gradle_binary(self):
7070
gradle = SubprocessGradle(gradle_binary=self.gradle_binary, os_utils=self.os_utils)
7171
gradle.build(self.source_dir, self.manifest_path)
7272
self.os_utils.popen.assert_called_with(
73-
[self.gradle_path, "build", "--build-file", self.manifest_path],
73+
[self.gradle_path, "build"],
7474
cwd=self.source_dir,
7575
stderr=subprocess.PIPE,
7676
stdout=subprocess.PIPE,
@@ -80,7 +80,7 @@ def test_build_with_init_script(self):
8080
gradle = SubprocessGradle(gradle_binary=self.gradle_binary, os_utils=self.os_utils)
8181
gradle.build(self.source_dir, self.manifest_path, init_script_path=self.init_script)
8282
self.os_utils.popen.assert_called_with(
83-
[self.gradle_path, "build", "--build-file", self.manifest_path, "--init-script", self.init_script],
83+
[self.gradle_path, "build", "--init-script", self.init_script],
8484
cwd=self.source_dir,
8585
stderr=subprocess.PIPE,
8686
stdout=subprocess.PIPE,
@@ -101,8 +101,6 @@ def test_includes_build_properties_in_command(self):
101101
[
102102
self.gradle_path,
103103
"build",
104-
"--build-file",
105-
self.manifest_path,
106104
"-Dfoo=bar",
107105
"--init-script",
108106
self.init_script,

0 commit comments

Comments
 (0)