Skip to content

Commit

Permalink
Extracted more common build logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jlink committed Dec 17, 2024
1 parent 4380c00 commit bba395b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
plugins {
java
}

repositories {
mavenCentral()
maven {
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
}
}

dependencies {
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
id("buildlogic.repositories")
id("buildlogic.use-junit-platform")
}

val javaVersion: String = System.getProperty("matrix.version") ?: "21"
val javaVendor: String = System.getProperty("matrix.vendor") ?: ""

// println("Using Java version: $javaVersion - $javaVendor")

java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
vendor = JvmVendorSpec.matching(javaVendor)
}
// jqwik2 has Java 21 as its base version
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
Expand All @@ -34,21 +24,4 @@ tasks.withType<JavaCompile> {
tasks.compileTestJava {
// Enable source parameter names through reflection
options.compilerArgs.add("-parameters")
}

tasks.named<Test>("test") {
useJUnitPlatform {
includeEngines("junit-jupiter")
}

include("**/*Example.class")
include("**/*Examples.class")
include("**/*Test.class")
include("**/*Tests.class")

reports {
junitXml.required = true
}

testLogging.showStandardStreams = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,20 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

fun alias(alias: String): Provider<MinimalExternalModuleDependency> {
return versionCatalogs.named("libs").findLibrary(alias).orElseThrow()
}

plugins {
`java-library`
id("buildlogic.publish-library")
id("buildlogic.repositories")
id("buildlogic.use-junit-platform")
kotlin("jvm")
kotlin("plugin.power-assert")
}

repositories {
mavenCentral()
maven {
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
}
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
powerAssert {
functions = listOf("kotlin.assert", "kotlin.test.assertTrue", "kotlin.test.assertEquals", "kotlin.test.assertNull")
}

dependencies {
testRuntimeOnly(alias("junit.platform.launcher"))
}

tasks.named<Test>("test") {
useJUnitPlatform {
includeEngines("junit-jupiter")
}

include("**/*Example.class")
include("**/*Examples.class")
include("**/*Test.class")
include("**/*Tests.class")

reports {
junitXml.required = true
}

testLogging.showStandardStreams = true
}

val kotlinCompilerArgs = listOf(
"[email protected]:strict",
"-Xemit-jvm-type-annotations" // Required for annotations on type variables
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repositories {
mavenCentral()
maven {
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
java
}

fun alias(alias: String): Provider<MinimalExternalModuleDependency> {
return versionCatalogs.named("libs").findLibrary(alias).orElseThrow()
}

dependencies {
testRuntimeOnly(alias("junit.platform.launcher"))
}

tasks.named<Test>("test") {
useJUnitPlatform {
includeEngines("junit-jupiter")
}

include("**/*Example.class")
include("**/*Examples.class")
include("**/*Test.class")
include("**/*Tests.class")

reports {
junitXml.required = true
}

testLogging.showStandardStreams = true
}

0 comments on commit bba395b

Please sign in to comment.