Skip to content

Commit

Permalink
Revert "Use Provider API to read version and changes files"
Browse files Browse the repository at this point in the history
This reverts commit 7c7f5a6.
  • Loading branch information
erichaagdev committed Apr 14, 2023
1 parent 422822e commit 86a4731
Showing 1 changed file with 31 additions and 35 deletions.
66 changes: 31 additions & 35 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ repositories {
mavenCentral()
}

val releaseVersion = releaseVersion()
val releaseNotes = releaseNotes()

val appVersion = layout.projectDirectory.file("release/version.txt").asFile.readText().trim()
allprojects {
version = releaseVersion
version = appVersion
}

val argbash by configurations.creating
Expand Down Expand Up @@ -95,18 +93,16 @@ val copyGradleScripts by tasks.registering(Copy::class) {
group = "build"
description = "Copies the Gradle source and generated scripts to output directory."

// local variable required for configuration cache compatibility
// https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:not_yet_implemented:accessing_top_level_at_execution
val releaseVersion = releaseVersion
inputs.property("project.version", releaseVersion)
val projectVersion = appVersion // local variable required for configuration cache compatibility
inputs.property("project.version", projectVersion)

from(layout.projectDirectory.file("LICENSE"))
from(layout.projectDirectory.dir("release").file("version.txt"))
rename("version.txt", "VERSION")

from(layout.projectDirectory.dir("components/scripts/gradle")) {
exclude("gradle-init-scripts")
filter { line: String -> line.replace("<HEAD>", releaseVersion.get()) }
filter { line: String -> line.replace("<HEAD>", projectVersion) }
}
from(layout.projectDirectory.dir("components/scripts/gradle")) {
include("gradle-init-scripts/**")
Expand All @@ -118,7 +114,7 @@ val copyGradleScripts by tasks.registering(Copy::class) {
include("network.settings")
include("lib/**")
exclude("lib/cli-parsers")
filter { line: String -> line.replace("<HEAD>", releaseVersion.get()) }
filter { line: String -> line.replace("<HEAD>", projectVersion) }
}
from(generateBashCliParsers.map { it.outputDir.file("lib/cli-parsers/gradle") }) {
into("lib/")
Expand All @@ -133,25 +129,23 @@ val copyMavenScripts by tasks.registering(Copy::class) {
group = "build"
description = "Copies the Maven source and generated scripts to output directory."

// local variable required for configuration cache compatibility
// https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:not_yet_implemented:accessing_top_level_at_execution
val releaseVersion = releaseVersion
inputs.property("project.version", releaseVersion)
val projectVersion = appVersion // local variable required for configuration cache compatibility
inputs.property("project.version", projectVersion)

from(layout.projectDirectory.file("LICENSE"))
from(layout.projectDirectory.dir("release").file("version.txt"))
rename("version.txt", "VERSION")

from(layout.projectDirectory.dir("components/scripts/maven")) {
filter { line: String -> line.replace("<HEAD>", releaseVersion.get()) }
filter { line: String -> line.replace("<HEAD>", projectVersion) }
}
from(layout.projectDirectory.dir("components/scripts/")) {
include("README.md")
include("mapping.example")
include("network.settings")
include("lib/**")
exclude("lib/cli-parsers")
filter { line: String -> line.replace("<HEAD>", releaseVersion.get()) }
filter { line: String -> line.replace("<HEAD>", projectVersion) }
}
from(generateBashCliParsers.map { it.outputDir.file("lib/cli-parsers/maven") }) {
into("lib/")
Expand All @@ -175,7 +169,7 @@ val assembleGradleScripts by tasks.registering(Zip::class) {
group = "build"
description = "Packages the Gradle experiment scripts in a zip archive."
archiveBaseName.set("gradle-enterprise-gradle-build-validation")
archiveFileName.set("${archiveBaseName.get()}-${distributionVersion().get()}.zip")
archiveFileName.set("${archiveBaseName.get()}-${distributionVersion()}.zip")
from(copyGradleScripts)
into(archiveBaseName.get())
}
Expand All @@ -184,7 +178,7 @@ val assembleMavenScripts by tasks.registering(Zip::class) {
group = "build"
description = "Packages the Maven experiment scripts in a zip archive."
archiveBaseName.set("gradle-enterprise-maven-build-validation")
archiveFileName.set("${archiveBaseName.get()}-${distributionVersion().get()}.zip")
archiveFileName.set("${archiveBaseName.get()}-${distributionVersion()}.zip")
from(copyMavenScripts)
into(archiveBaseName.get())
}
Expand Down Expand Up @@ -259,7 +253,7 @@ githubRelease {
prerelease.set(isDevelopmentRelease)
overwrite.set(isDevelopmentRelease)
generateReleaseNotes.set(false)
body.set(releaseNotes)
body.set(layout.projectDirectory.file("release/changes.md").asFile.readText().trim())
releaseAssets(assembleGradleScripts, assembleMavenScripts, generateChecksums.map { it.outputs.files.asFileTree })
}

Expand All @@ -278,24 +272,26 @@ tasks.withType(Sign::class).configureEach {
notCompatibleWithConfigurationCache("$name task does not support configuration caching")
}

fun gitHubReleaseName(): Provider<String> {
return releaseVersion.map { if (isDevelopmentRelease) "Development release" else it }
}

fun gitReleaseTag(): Provider<String> {
return releaseVersion.map { if (isDevelopmentRelease) "development-latest" else "v$it" }
}

fun distributionVersion(): Provider<String> {
return releaseVersion.map { if (isDevelopmentRelease) "dev" else it }
fun gitHubReleaseName(): String {
if (isDevelopmentRelease) {
return "Development Build"
} else {
return version.toString()
}
}

fun releaseVersion(): Provider<String> {
val versionFile = layout.projectDirectory.file("release/version.txt")
return providers.fileContents(versionFile).asText.map { it.trim() }
fun gitReleaseTag(): String {
if (isDevelopmentRelease) {
return "development-latest"
} else {
return "v${version}"
}
}

fun releaseNotes(): Provider<String> {
val releaseNotesFile = layout.projectDirectory.file("release/changes.md")
return providers.fileContents(releaseNotesFile).asText.map { it.trim() }
fun distributionVersion(): String {
if (isDevelopmentRelease) {
return "dev"
} else {
return version.toString()
}
}

0 comments on commit 86a4731

Please sign in to comment.