Skip to content

Adopt Foojay Toolchains and Kotlin DSL plugins in build logic #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The build validation scripts are available as pre-built, executable Bash scripts

## Build from source

You can also assemble the build validation scripts from source by running `./gradlew build` from the root folder of this repository. If you run the build on a M1-Apple machine, the build requires Java 8 to already be installed. This requirement is due to Gradle currently not being able to download Java 8 via its Toolchain feature.
You can also assemble the build validation scripts from source by running `./gradlew build` from the root folder of this repository.

Once the build has finished successfully, you can find two .zip files in the build/distributions folder: one .zip file containing the build validation scripts for Gradle and one .zip file containing the build validation scripts for Maven.

Expand Down
9 changes: 7 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
plugins {
kotlin("jvm") version "1.8.10"
`kotlin-dsl`
}

kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8))
languageVersion.set(JavaLanguageVersion.of(8))

// Azul has been chosen due to its wide range of supported platforms for
// Java 8, including arm64 for macOS.
// See: https://foojay.io/almanac/jdk-8
vendor.set(JvmVendorSpec.AZUL)
}
}

Expand Down
5 changes: 5 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0"
}

rootProject.name = "buildSrc"
14 changes: 7 additions & 7 deletions buildSrc/src/main/kotlin/ApplyArgbash.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ abstract class ApplyArgbash @Inject constructor(
fun applyArgbash() {
val argbash = argbashHome.get().file("bin/argbash").asFile
scriptTemplates.get().visit {
if(!it.isDirectory) {
val relPath = it.relativePath.parent.pathString
val basename = it.file.nameWithoutExtension
val outputFile = outputDir.get().file("${relPath}/${basename}.sh").asFile
if(!isDirectory) {
val relPath = relativePath.parent.pathString
val basename = file.nameWithoutExtension
val outputFile = outputDir.get().file("$relPath/$basename.sh").asFile
outputFile.parentFile.mkdirs()

logger.info("Applying argbash to $it.file")
execOperations.exec { execSpec ->
execSpec.commandLine(argbash, it.file, "-o", outputFile)
logger.info("Applying argbash to $file")
execOperations.exec {
commandLine(argbash, file, "-o", outputFile)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/CreateGitTag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ abstract class CreateGitTag @Inject constructor(
@TaskAction
fun applyArgbash() {
logger.info("Tagging HEAD as ${tagName.get()}")
execOperations.exec { execSpec ->
execOperations.exec {
val args = mutableListOf("git", "tag")
if (overwriteExisting.get()) {
args.add("-f")
}
args.add(tagName.get())
execSpec.commandLine(args)
commandLine(args)
}
execOperations.exec { execSpec ->
execOperations.exec {
val args = mutableListOf("git", "push", "origin")
if (overwriteExisting.get()) {
args.add("-f")
}
args.add("--tags")
execSpec.commandLine(args)
commandLine(args)
}
}
}