Skip to content

Commit

Permalink
Replace soon-to-be-deprecated usages of project.buildDir
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Jul 20, 2023
1 parent 463ae36 commit 45b970f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
16 changes: 8 additions & 8 deletions documentation/documentation.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ asciidoctorj {
val snapshot = rootProject.version.toString().contains("SNAPSHOT")
val docsVersion = if (snapshot) "snapshot" else rootProject.version
val releaseBranch = if (snapshot) "HEAD" else "r${rootProject.version}"
val docsDir = file("$buildDir/ghpages-docs")
val docsDir = layout.buildDirectory.dir("ghpages-docs")
val replaceCurrentDocs = buildParameters.documentation.replaceCurrentDocs
val uploadPdfs = !snapshot
val userGuidePdfFileName = "junit-user-guide-${rootProject.version}.pdf"
Expand Down Expand Up @@ -109,7 +109,7 @@ val deprecatedApisTableFile = generatedAsciiDocPath.map { it.file("deprecated-ap
val standaloneConsoleLauncherShadowedArtifactsFile = generatedAsciiDocPath.map { it.file("console-launcher-standalone-shadowed-artifacts.adoc") }

val jdkJavadocBaseUrl = "https://docs.oracle.com/en/java/javase/11/docs/api"
val elementListsDir = file("$buildDir/elementLists")
val elementListsDir = layout.buildDirectory.dir("elementLists")
val externalModulesWithoutModularJavadoc = mapOf(
"org.apiguardian.api" to "https://apiguardian-team.github.io/apiguardian/docs/$apiGuardianDocVersion/api/",
"org.assertj.core" to "https://javadoc.io/doc/org.assertj/assertj-core/${libs.versions.assertj.get()}/",
Expand Down Expand Up @@ -314,7 +314,7 @@ tasks {
doFirst {
externalModulesWithoutModularJavadoc.forEach { (moduleName, baseUrl) ->
val resource = resources.text.fromUri("${baseUrl}element-list")
elementListsDir.resolve(moduleName).apply {
elementListsDir.get().asFile.resolve(moduleName).apply {
mkdir()
resolve("element-list").writeText("module:$moduleName\n${resource.asString()}")
}
Expand Down Expand Up @@ -356,7 +356,7 @@ tasks {
links(jdkJavadocBaseUrl)
links("https://junit.org/junit4/javadoc/${libs.versions.junit4.get()}/")
externalModulesWithoutModularJavadoc.forEach { (moduleName, baseUrl) ->
linksOffline(baseUrl, "$elementListsDir/$moduleName")
linksOffline(baseUrl, elementListsDir.get().asFile.resolve(moduleName).absolutePath)
}

groups = mapOf(
Expand Down Expand Up @@ -387,7 +387,7 @@ tasks {
classpath = files(modularProjects.map { it.sourceSets.main.get().compileClasspath })

maxMemory = "1024m"
destinationDir = file("$buildDir/docs/javadoc")
destinationDir = layout.buildDirectory.dir("docs/javadoc").get().asFile

doFirst {
(options as CoreJavadocOptions).modulePath = classpath.files.toList()
Expand Down Expand Up @@ -417,14 +417,14 @@ tasks {
}
}
}
into("$buildDir/docs/fixedJavadoc")
into(layout.buildDirectory.dir("docs/fixedJavadoc"))
}

val prepareDocsForUploadToGhPages by registering(Copy::class) {
dependsOn(fixJavadoc, asciidoctor, asciidoctorPdf)
outputs.dir(docsDir)

from("$buildDir/checksum") {
from(layout.buildDirectory.dir("checksum")) {
include("published-checksum.txt")
}
from(asciidoctor.map { it.outputDir }) {
Expand All @@ -441,7 +441,7 @@ tasks {
from(fixJavadoc.map { it.destinationDir }) {
into("api")
}
into("$docsDir/$docsVersion")
into(docsDir.map { it.dir(docsVersion.toString()) })
includeEmptyDirs = false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ val builtByValue: String by rootProject.extra

val extension = extensions.create<JavaLibraryExtension>("javaLibrary")

val moduleSourceDir = file("src/module/$javaModuleName")
val moduleSourceDir = layout.projectDirectory.dir("src/module/$javaModuleName")
val combinedModuleSourceDir = layout.buildDirectory.dir("module")
val moduleOutputDir = file("$buildDir/classes/java/module")
val moduleOutputDir = layout.buildDirectory.dir("classes/java/module")
val javaVersion = JavaVersion.current()

eclipse {
Expand Down Expand Up @@ -194,7 +194,7 @@ tasks.withType<Jar>().configureEach {
val suffix = archiveClassifier.getOrElse("")
if (suffix.isBlank() || this is ShadowJar) {
dependsOn(allMainClasses, compileModule)
from("$moduleOutputDir/$javaModuleName") {
from(moduleOutputDir.map { it.dir(javaModuleName) }) {
include("module-info.class")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.gradle.configurationcache.extensions.capitalized

val tempRepoName by extra("temp")
val tempRepoDir by extra(file("$buildDir/repo"))
val tempRepoDir by extra {
layout.buildDirectory.dir("repo").get().asFile
}

val clearTempRepoDir by tasks.registering {
val dir = tempRepoDir
Expand Down

0 comments on commit 45b970f

Please sign in to comment.