Polish "Replace deprecated method getBuildDir()"

See gh-31416
This commit is contained in:
Stéphane Nicoll 2023-10-12 16:14:23 +02:00
parent 35103b0cd1
commit d05ac097dd
2 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -131,9 +131,9 @@ public class ApiDiffPlugin implements Plugin<Project> {
} }
private File getOutputFile(String baseLineVersion, Project project) { private File getOutputFile(String baseLineVersion, Project project) {
Path outDir = Paths.get(project.getRootProject() String buildDirectoryPath = project.getRootProject()
.getLayout().getBuildDirectory().getAsFile().get().getAbsolutePath(), .getLayout().getBuildDirectory().getAsFile().get().getAbsolutePath();
"reports", "api-diff", Path outDir = Paths.get(buildDirectoryPath, "reports", "api-diff",
baseLineVersion + "_to_" + project.getRootProject().getVersion()); baseLineVersion + "_to_" + project.getRootProject().getVersion());
return project.file(outDir.resolve(project.getName() + ".html").toString()); return project.file(outDir.resolve(project.getName() + ".html").toString());
} }

View File

@ -47,7 +47,8 @@ rootProject.children.each {project ->
settings.gradle.projectsLoaded { settings.gradle.projectsLoaded {
gradleEnterprise { gradleEnterprise {
buildScan { buildScan {
File buildDir = settings.gradle.rootProject.getLayout().getBuildDirectory().getAsFile().get() File buildDir = settings.gradle.rootProject
.getLayout().getBuildDirectory().getAsFile().get()
buildDir.mkdirs() buildDir.mkdirs()
new File(buildDir, "build-scan-uri.txt").text = "(build scan not generated)" new File(buildDir, "build-scan-uri.txt").text = "(build scan not generated)"
buildScanPublished { scan -> buildScanPublished { scan ->