Skip to content
This repository has been archived by the owner on Feb 2, 2025. It is now read-only.

Commit

Permalink
Adding version catalogs, gradle convention plugin (#206)
Browse files Browse the repository at this point in the history
* Adding version catalogs, gradle convention plugin

* Solve build issues

* Apply suggestions from code review

Co-authored-by: Imran Malic Settuba <[email protected]>

* Resolve kotest version from version catalog in convention plugin

* Revert "Apply suggestions from code review"

This reverts commit d1acee6.

* Fix build

Co-authored-by: Imran Malic Settuba <[email protected]>
  • Loading branch information
Kantis and i-walker authored Jul 1, 2022
1 parent b33f660 commit 3370c64
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 574 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

48 changes: 0 additions & 48 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,48 +0,0 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

repositories {
mavenCentral()
}

plugins {
java
kotlin("multiplatform").version("1.6.20") apply false
`java-library`
id("maven-publish")
signing
id("org.jetbrains.dokka") version "1.6.21"
id("io.kotest.multiplatform") version "5.3.0"
id("ru.vyarus.animalsniffer") version "1.5.4"
}

allprojects {
group = "io.kotest.extensions"
version = Ci.version

repositories {
mavenCentral()
gradlePluginPortal()
}

apply(plugin = "ru.vyarus.animalsniffer")
apply(plugin = "java")
apply(plugin = "java-library")
apply(plugin = "io.kotest.multiplatform")
apply(plugin = "maven-publish")

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
}
}

subprojects {
apply(plugin = "org.jetbrains.kotlin.multiplatform")
}

val publications: PublicationContainer = (extensions.getByName("publishing") as PublishingExtension).publications

signing {
useGpgCmd()
if (Ci.isRelease)
sign(publications)
}
13 changes: 6 additions & 7 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import org.gradle.kotlin.dsl.`kotlin-dsl`

buildscript {
repositories {
mavenCentral()
}
}

repositories {
mavenCentral()
mavenLocal()
gradlePluginPortal()
}

plugins {
`kotlin-dsl`
}

dependencies {
implementation(libs.kotlin.gradle.plugin)
implementation(libs.animalsniffer)
}
7 changes: 7 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
186 changes: 186 additions & 0 deletions buildSrc/src/main/kotlin/kotest-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.kotlin.dsl.all
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.named

plugins {
`java-library`
kotlin("multiplatform")
id("ru.vyarus.animalsniffer")
}

repositories {
mavenCentral()
mavenLocal()
gradlePluginPortal()
}

group = "io.kotest.extensions"
version = Ci.version

kotlin {
explicitApi()

targets {
metadata()

jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
}

js(IR) {
browser()
nodejs()
}

linuxX64()

mingwX64()

iosArm32()
iosArm64()
iosSimulatorArm64()
iosX64()
macosArm64()
macosX64()
tvosArm64()
tvosSimulatorArm64()
tvosX64()
watchosArm32()
watchosArm64()
watchosSimulatorArm64()
watchosX64()
watchosX86()
}

sourceSets {
val commonMain by getting
val commonTest by getting {
dependsOn(commonMain)
}

val jvmMain by getting {
dependsOn(commonMain)
}

val kotestVersion = resolveVersion("kotest")

val jvmTest by getting {
dependsOn(commonTest)
dependsOn(jvmMain)
dependencies {
implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
}
}

val jsMain by getting {
dependsOn(commonMain)
}

val jsTest by getting {
dependsOn(commonTest)
dependsOn(jsMain)
}

val mingwX64Main by getting
val linuxX64Main by getting
val iosArm32Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosX64Main by getting
val macosArm64Main by getting
val macosX64Main by getting
val tvosArm64Main by getting
val tvosSimulatorArm64Main by getting
val tvosX64Main by getting
val watchosArm32Main by getting
val watchosArm64Main by getting
val watchosSimulatorArm64Main by getting
val watchosX64Main by getting
val watchosX86Main by getting

val nativeMain by creating {
dependsOn(commonMain)
mingwX64Main.dependsOn(this)
linuxX64Main.dependsOn(this)
iosArm32Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
iosX64Main.dependsOn(this)
macosArm64Main.dependsOn(this)
macosX64Main.dependsOn(this)
tvosArm64Main.dependsOn(this)
tvosSimulatorArm64Main.dependsOn(this)
tvosX64Main.dependsOn(this)
watchosArm32Main.dependsOn(this)
watchosArm64Main.dependsOn(this)
watchosSimulatorArm64Main.dependsOn(this)
watchosX64Main.dependsOn(this)
watchosX86Main.dependsOn(this)
}

val mingwX64Test by getting
val linuxX64Test by getting
val iosArm32Test by getting
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val iosX64Test by getting
val macosArm64Test by getting
val macosX64Test by getting
val tvosArm64Test by getting
val tvosSimulatorArm64Test by getting
val tvosX64Test by getting
val watchosArm32Test by getting
val watchosArm64Test by getting
val watchosSimulatorArm64Test by getting
val watchosX64Test by getting
val watchosX86Test by getting

create("nativeTest") {
dependsOn(nativeMain)
dependsOn(commonTest)
mingwX64Test.dependsOn(this)
linuxX64Test.dependsOn(this)
iosArm32Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
iosX64Test.dependsOn(this)
macosArm64Test.dependsOn(this)
macosX64Test.dependsOn(this)
tvosArm64Test.dependsOn(this)
tvosSimulatorArm64Test.dependsOn(this)
tvosX64Test.dependsOn(this)
watchosArm32Test.dependsOn(this)
watchosArm64Test.dependsOn(this)
watchosSimulatorArm64Test.dependsOn(this)
watchosX64Test.dependsOn(this)
watchosX86Test.dependsOn(this)
}

all {
languageSettings.optIn("kotlin.RequiresOptIn")
}
}
}

animalsniffer {
ignore = listOf("java.lang.*")
}

tasks.named<Test>("jvmTest") {
useJUnitPlatform()
maxParallelForks = Runtime.getRuntime().availableProcessors()
testLogging {
showExceptions = true
showStandardStreams = true
events = setOf(
TestLogEvent.FAILED,
TestLogEvent.PASSED
)
exceptionFormat = TestExceptionFormat.FULL
}
}
10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/versionCatalog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.getByType

// Workaround for https://github.com/gradle/gradle/issues/15383
fun Project.resolveVersion(name: String) =
extensions.getByType<VersionCatalogsExtension>()
.named("libs")
.findVersion(name)
.get().requiredVersion
23 changes: 23 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[versions]
arrow = "1.1.2"
kotlin = "1.6.21"
kotest = "5.3.2"

[libraries]
kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" }
kotest-framework-api = { module = "io.kotest:kotest-framework-api", version.ref = "kotest" }
kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" }

kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.6.3" }

arrow-fx-coroutines = { module = "io.arrow-kt:arrow-fx-coroutines", version.ref = "arrow" }
arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" }
arrow-optics = { module = "io.arrow-kt:arrow-optics", version.ref = "arrow" }

# Gradle plugins used in buildSrc
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
animalsniffer = { module = "ru.vyarus:gradle-animalsniffer-plugin", version = "1.5.4" }

[plugins]
Loading

0 comments on commit 3370c64

Please sign in to comment.