Skip to content

Commit

Permalink
Further optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpedromoreno committed Jun 8, 2023
1 parent e91a340 commit 3458b92
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 46 deletions.
23 changes: 7 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,15 @@ jobs:
distribution: 'zulu'
java-version: 19

- name: Setup Gradle
- name: Build and Test (multip)
uses: gradle/gradle-build-action@v2
with:
arguments: buildAndTestMultip -Pplatform=${{ matrix.platform }}

- name: Build and Test (multip/no Windows)
run: ./gradlew buildAndTestMultip -Pplatform=${{ matrix.platform }} -PgradleCommand=./gradlew
if: ${{ matrix.platform != 'mingwX64' }}

- name: Build and Test (multip/Windows)
run: cmd.exe /c gradlew.bat buildAndTestMultip -Pplatform=${{ matrix.platform }} -PgradleCommand='gradlew.bat'
if: ${{ matrix.platform == 'mingwX64' }}

- name: Build and Test (singlep/No Windows)
run: ./gradlew buildAndTestSinglep -PgradleCommand=./gradlew
if: ${{ matrix.platform == 'jvm' && matrix.platform != 'mingwX64' }}

- name: Build and Test (singlep/Windows)
run: ./gradlew buildAndTestSinglep -PgradleCommand='gradlew.bat'
if: ${{ matrix.platform == 'jvm' && matrix.platform == 'mingwX64' }}
- name: Build and Test (singlep)
uses: gradle/gradle-build-action@v2
with:
arguments: buildAndTestSinglep -Pplatform=${{ matrix.platform }}

- name: Upload reports
if: failure()
Expand Down
74 changes: 44 additions & 30 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,53 @@ allprojects {
group = property("project.group").toString()
}

tasks.register("buildAndTestMultip") {
val platform: String by project.extensions.extraProperties
val gradleCommand: String by project.extensions.extraProperties

doLast {
project.exec {
commandLine(gradleCommand,
"spotlessCheck",
":xef-core:${platform}Test",
":xef-filesystem:${platform}Test",
":xef-tokenizer:${platform}Test"
)
val multiPlatformModules = listOf(
"xef-core",
"xef-filesystem",
"xef-tokenizer"
)

fun Project.configureBuildAndTestTask(
taskName: String,
multiPlatformModules: List<String>,
singlePlatformCommand: String
) {
val platform: String by extra

tasks.register(taskName) {
doLast {
project.exec {
val gradleCommand = getGradleCommand(platform)
commandLine(gradleCommand, "spotlessCheck")
if (multiPlatformModules.isNotEmpty()) {
multiPlatformModules.forEach { module ->
commandLine(gradleCommand, ":$module:${platform}Test")
}
} else {
val excludedModules = multiPlatformModules.map { ":$it:build" }
commandLine(gradleCommand, singlePlatformCommand, "-x", excludedModules.joinToString(" -x "))
}
}
}
}
}

tasks.register("buildAndTestSinglep") {
val gradleCommand: String by project.extensions.extraProperties

doLast {
project.exec {
commandLine(gradleCommand,
"spotlessCheck",
":xef-lucene:build",
":xef-pdf:build",
":xef-postgresql:build",
":xef-sql:build",
":xef-kotlin-examples:build",
":kotlin-loom:build",
":xef-scala-examples:build",
":xef-scala:build",
":xef-scala-cats:build"
)
}
fun getGradleCommand(platform: String): String {
return if (platform == "mingwX64") {
"gradlew.bat"
} else {
"./gradlew"
}
}

configureBuildAndTestTask(
"buildAndTestMultip",
multiPlatformModules,
""
)

configureBuildAndTestTask(
"buildAndTestSinglep",
multiPlatformModules,
"build"
)

0 comments on commit 3458b92

Please sign in to comment.