From 9623871b680117136818b5ac68d9fb8745d1ea13 Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Mon, 9 Oct 2023 11:05:26 +0100 Subject: [PATCH] Fix references to Gradle buildDirectory since upgrading to 8.4 (#2379) --- build.gradle.kts | 2 +- .../digital/hmpps/plugins/ClassPathPlugin.kt | 4 +++- .../digital/hmpps/plugins/JibConfigPlugin.kt | 17 +++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index df6783e34a..d973859685 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,7 @@ dependencies { val copyAgentTask = project.tasks.register("copyAgent") { from(agentDeps) - into("${project.layout.buildDirectory}/agent") + into("${project.layout.buildDirectory.dir("agent").get().asFile}") rename("applicationinsights-agent(.+).jar", "agent.jar") } diff --git a/buildSrc/src/main/kotlin/uk/gov/justice/digital/hmpps/plugins/ClassPathPlugin.kt b/buildSrc/src/main/kotlin/uk/gov/justice/digital/hmpps/plugins/ClassPathPlugin.kt index ee448050fc..4ec504ee83 100644 --- a/buildSrc/src/main/kotlin/uk/gov/justice/digital/hmpps/plugins/ClassPathPlugin.kt +++ b/buildSrc/src/main/kotlin/uk/gov/justice/digital/hmpps/plugins/ClassPathPlugin.kt @@ -45,7 +45,9 @@ class ClassPathPlugin : Plugin { classDirectories.files.map { project.fileTree(it) { exclude(extension.jacocoExclusions) } } ) ) - executionData.setFrom(project.fileTree(project.layout.buildDirectory).include("/jacoco/*.exec")) + executionData + .setFrom(project.fileTree(project.layout.buildDirectory.get().asFile.path) + .include("/jacoco/*.exec")) reports { html.required.set(true) xml.required.set(true) diff --git a/buildSrc/src/main/kotlin/uk/gov/justice/digital/hmpps/plugins/JibConfigPlugin.kt b/buildSrc/src/main/kotlin/uk/gov/justice/digital/hmpps/plugins/JibConfigPlugin.kt index 814c77be94..e27d7c0694 100644 --- a/buildSrc/src/main/kotlin/uk/gov/justice/digital/hmpps/plugins/JibConfigPlugin.kt +++ b/buildSrc/src/main/kotlin/uk/gov/justice/digital/hmpps/plugins/JibConfigPlugin.kt @@ -30,11 +30,11 @@ class JibConfigPlugin : Plugin { extraDirectories { paths { path { - setFrom("${project.rootProject.layout.buildDirectory}") + setFrom("${project.rootProject.layout.buildDirectory.get().asFile}") includes.add("agent/agent.jar") } path { - setFrom("${project.layout.buildDirectory}/agent") + setFrom("${project.layout.buildDirectory.dir("agent").get().asFile}") includes.add("applicationinsights*.json") into = "/agent" } @@ -45,7 +45,7 @@ class JibConfigPlugin : Plugin { val copyAgent = project.rootProject.tasks.named("copyAgent") val copyAppInsightsConfig = project.tasks.register("copyAppInsightsConfig") { from("${project.projectDir}/applicationinsights.json") - into("${project.layout.buildDirectory}/agent") + into("${project.layout.buildDirectory.dir("agent").get().asFile}") } val assemble = project.tasks.named("assemble") project.tasks.withType().named("jib") { @@ -69,14 +69,15 @@ class JibConfigPlugin : Plugin { } dependsOn(copyAgent, copyAppInsightsConfig, assemble) inputs.dir("deploy") + val buildDir = project.layout.buildDirectory.get().asFile.path inputs.files( - "${project.layout.buildDirectory}/agent", - "${project.layout.buildDirectory}/classes", - "${project.layout.buildDirectory}/generated", - "${project.layout.buildDirectory}/resources", + "$buildDir/agent", + "$buildDir/classes", + "$buildDir/generated", + "$buildDir/resources", project.configurations[jib!!.configurationName.get()].resolvedConfiguration.files ) - outputs.file("${project.layout.buildDirectory}/jib-image.id") + outputs.file("$buildDir/jib-image.id") outputs.cacheIf { true } } }