Skip to content

Commit

Permalink
Initial multiplatform exploration
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvanyo committed Aug 21, 2021
1 parent f69055d commit 9e8e184
Show file tree
Hide file tree
Showing 118 changed files with 1,006 additions and 404 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ jobs:
java-version: ${{ matrix.java-version }}

- name: Test
run: ./gradlew check jacocoTestReport
run: ./gradlew check jacocoTestReport --no-parallel

- name: cat
run: cat build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml

- name: Danger
# Run Danger for PRs originating from within the repo (for fork PRs the token won't give permission to comment)
Expand Down
2 changes: 1 addition & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
shroud.report 'build/reports/jacoco/test/jacocoTestReport.xml', 80, 80, false
shroud.report 'build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml', 80, 80, false
126 changes: 49 additions & 77 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

plugins {
kotlin("jvm") version Versions.kotlin
kotlin("multiplatform") version Versions.kotlin apply false
jacoco
id("io.gitlab.arturbosch.detekt") version Versions.detekt
id("org.jetbrains.dokka") version Versions.dokka
Expand All @@ -16,88 +16,23 @@ allprojects {
}

subprojects {
apply {
plugin<org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper>()
plugin<JacocoPlugin>()
plugin<io.gitlab.arturbosch.detekt.DetektPlugin>()
plugin<org.jetbrains.dokka.gradle.DokkaPlugin>()
}

dependencies {
detektPlugins(Dependencies.detektFormatting)
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlin {
explicitApi()
}

tasks {
compileKotlin {
withType<org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
allWarningsAsErrors = true
}
}

compileTestKotlin {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
allWarningsAsErrors = true
}
}

test {
useJUnitPlatform()
}

jacoco {
toolVersion = Versions.jacoco
}

jacocoTestReport {
dependsOn(test)

reports {
html.isEnabled = true
xml.isEnabled = true
}
}

withType<io.gitlab.arturbosch.detekt.Detekt> {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

check {
dependsOn("detektMain")
}

dokkaHtml {
outputDirectory.set(javadoc.get().destinationDir)
}

plugins.withType(MavenPublishPlugin::class) {
val sourcesJar by creating(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}

val javadocJar by creating(Jar::class) {
archiveClassifier.set("javadoc")
from(dokkaHtml)
}

publishing {
publications {
create<MavenPublication>("default") {
from(this@subprojects.components["java"])
artifact(sourcesJar)
artifact(javadocJar)

pom {
name.set(project.name)
description.set("Obsoleting enums with sealed classes of objects")
Expand Down Expand Up @@ -143,22 +78,59 @@ apiValidation {

tasks {
val jacocoMergeTest by registering(JacocoMerge::class) {
dependsOn(subprojects.map { it.tasks.jacocoTestReport })

destinationFile = file("$buildDir/jacoco/test.exec")
executionData = fileTree(rootDir) {
include("**/build/jacoco/test.exec")
}
val subprojectReporters = listOf(
"ksp",
"processor",
"processing-tests/ksp-tests",
"processing-tests/processor-tests",
"runtime"
)

dependsOn(subprojectReporters.map { "${it.replace("/", ":")}:jacocoTestReport" })

destinationFile = file("$buildDir/jacoco/jvmTest.exec")
executionData = files(
subprojectReporters
.map { file("$it/build/jacoco/jvmTest.exec") }
.filter(File::exists)
)
}

jacocoTestReport {
val jacocoTestReport by registering(JacocoReport::class) {
dependsOn(jacocoMergeTest)

sourceSets(*subprojects.map { it.sourceSets.main.get() }.toTypedArray())
executionData.setFrom("$buildDir/jacoco/jvmTest.exec")
classDirectories.setFrom(
files(
subprojects
.map {
it.buildDir.resolve("classes/kotlin/jvm/main")
}
.flatMap { it.walkBottomUp().toList() }
)
)
sourceDirectories.setFrom(
files(
subprojects.flatMap {
listOf(
it.projectDir.resolve("src/commonMain"),
it.projectDir.resolve("src/jvmMain")
).filter(File::exists)
}
)
)

reports {
html.isEnabled = true
xml.isEnabled = true
}
}

val detektAll by registering {
allprojects {
this@registering.dependsOn(tasks.withType<io.gitlab.arturbosch.detekt.Detekt>())
}

getByName("check").dependsOn(this)
}
}
1 change: 1 addition & 0 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ style:
excludedFunctions: 'describeContents'
excludeAnnotatedFunction: ['dagger.Provides']
LibraryCodeMustSpecifyReturnType:
excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ]
active: true
LibraryEntitiesShouldNotBePublic:
active: false
Expand Down
Loading

0 comments on commit 9e8e184

Please sign in to comment.