Skip to content

Commit

Permalink
Cleanup gradle build
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbrooks committed Jun 29, 2024
1 parent 92d9252 commit 8dd4646
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 50 deletions.
93 changes: 55 additions & 38 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,65 +1,82 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jlleitschuh.gradle.ktlint.KtlintExtension
import org.jlleitschuh.gradle.ktlint.KtlintPlugin

buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
}

dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
classpath("org.jlleitschuh.gradle:ktlint-gradle:12.1.0")
classpath("com.vanniktech:gradle-maven-publish-plugin:0.18.0")
}
plugins {
id("org.jetbrains.kotlin.jvm") version "2.0.0"
id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
id("com.vanniktech.maven.publish") version "0.29.0"
}

subprojects {
repositories {
mavenLocal()
mavenCentral()
}

apply<KtlintPlugin>()
configure<KtlintExtension> {
version.set("1.2.1")
}

pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
configure<KotlinProjectExtension> {
jvmToolchain(21)
configure<KotlinJvmProjectExtension> {
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
}

configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}

tasks.withType<Test> {
useJUnitPlatform()

testLogging {
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
}

addTestListener(object : TestListener {
override fun afterSuite(suite: TestDescriptor, result: TestResult) {
if (suite.parent == null) {
val output = "| Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped) |"
val border = "-".repeat(output.length)
println("""
$border
$output
$border
""".trimIndent()
)
addTestListener(
object : TestListener {
override fun afterSuite(
suite: TestDescriptor,
result: TestResult,
) {
if (suite.parent == null) {
val output =
buildString {
append("| Results: ")
append(result.resultType)
append(" (")
append(result.testCount)
append(" tests, ")
append(result.successfulTestCount)
append(" passed, ")
append(result.failedTestCount)
append(" failed, ")
append(result.skippedTestCount)
append(" skipped) |")
}
val border = "-".repeat(output.length)
println(
"""
$border
$output
$border
""".trimIndent(),
)
}
}
}

override fun afterTest(testDescriptor: TestDescriptor?, result: TestResult?) {}
override fun beforeTest(testDescriptor: TestDescriptor?) {}
override fun beforeSuite(suite: TestDescriptor?) {}
})
override fun afterTest(
testDescriptor: TestDescriptor?,
result: TestResult?,
) {}

override fun beforeTest(testDescriptor: TestDescriptor?) {}

override fun beforeSuite(suite: TestDescriptor?) {}
},
)
}
}
21 changes: 13 additions & 8 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/5.6/userguide/multi_project_builds.html
*/
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
}
}

include("vgo-core", "vgo", "vgo-plugin")
2 changes: 1 addition & 1 deletion vgo-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("org.jetbrains.kotlin.jvm")
id("java-gradle-plugin")
id("com.vanniktech.maven.publish")
id("org.gradle.kotlin.kotlin-dsl") version "4.3.0"
id("org.gradle.kotlin.kotlin-dsl") version "4.4.0"
}

dependencies {
Expand Down
8 changes: 5 additions & 3 deletions vgo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,18 @@ tasks {
dependsOn(getByName("jar"))
}

val binaryFile = file("$buildDir/libs/vgo")
val binaryFileProp = layout.buildDirectory.file("libs/vgo")
val binary by registering {
description = "Prepends shell script in the jar to improve CLI"
group = "build"

dependsOn(optimize)

inputs.file("build/libs/vgo.jar")
outputs.file(binaryFile)
outputs.file(binaryFileProp)

doLast {
val binaryFile = binaryFileProp.get().asFile
binaryFile.parentFile.mkdirs()
binaryFile.delete()
binaryFile.appendText("#!/bin/sh\n\nexec java \$JAVA_OPTS -jar \$0 \"\$@\"\n\n")
Expand All @@ -143,7 +144,8 @@ tasks {
description = "Updates baseline assets with the latest integration test outputs."
group = "Build Setup"

from("$buildDir/test-results/") {
val source = layout.buildDirectory.dir("test-results")
from(source) {
include("*testOptimizationFinishes.xml")
include("*testOptimizationFinishes.svg")
}
Expand Down

0 comments on commit 8dd4646

Please sign in to comment.