Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support native targets #6

Merged
merged 15 commits into from
Nov 21, 2022
Merged
73 changes: 37 additions & 36 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
`java-library`
`maven-publish`
signing
kotlin("jvm") version "1.7.20"
kotlin("multiplatform") version "1.7.20"
TWiStErRob marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this will download about 500MB extra on each CI, and additionally requires 2GB of permanent disk space on local machines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionally requires 2GB of permanent disk space on local machines. I think we have gradle caches so it is not a net new addition if the dev machine already compiles kotlin multiplatform?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the dev machine already compiles kotlin multiplatform

That's why I noticed it, this is the first KMP build I did.

we have gradle caches

I don't think ~/.konan is part of Gradle caches, it seems that Kotlin Native doesn't use the traditional Gradle features to download stuff. Anyway, not much we can do if we want to accept this build feature.

kotlin("plugin.serialization") version "1.7.20"
id("org.jetbrains.dokka") version "1.7.20"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dokka setup looks good. javadoc-silence.txt is not necessary although Dokka is quite noisy.

id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("org.owasp.dependencycheck") version "7.3.0"
}
Expand All @@ -17,41 +15,47 @@ repositories {
mavenCentral()
}

dependencies {
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
testImplementation(kotlin("stdlib"))
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
TWiStErRob marked this conversation as resolved.
Show resolved Hide resolved
}

tasks {
withType<KotlinCompile>().configureEach {
this.kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-opt-in=kotlinx.serialization.ExperimentalSerializationApi")
kotlin {
jvm {
TWiStErRob marked this conversation as resolved.
Show resolved Hide resolved
compilations.all {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
}
linuxX64()
mingwX64()
macosX64()
TWiStErRob marked this conversation as resolved.
Show resolved Hide resolved

withType<Javadoc>().configureEach {
val customArgs = projectDir.resolve("javadoc-silence.txt")
customArgs.writeText(
"""-Xdoclint:none
""".trimIndent()
)
options.optionFiles?.add(customArgs)
sourceSets {
all {
languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
}
val commonMain by getting {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("test"))
implementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
runtimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
}
}
}
}

tasks {
withType<Test>().configureEach {
useJUnitPlatform()
}
create<Jar>("dokkaJar") {
group = JavaBasePlugin.DOCUMENTATION_GROUP
archiveClassifier.set("javadoc")
from(dokkaHtml)
}
}

dependencyCheck {
Expand All @@ -60,11 +64,8 @@ dependencyCheck {

publishing {
publications {
register<MavenPublication>(rootProject.name) {
groupId = project.group as? String
artifactId = project.name
version = project.version as? String
from(components["java"])
TWiStErRob marked this conversation as resolved.
Show resolved Hide resolved
withType<MavenPublication> {
TWiStErRob marked this conversation as resolved.
Show resolved Hide resolved
artifact(tasks.findByName("dokkaJar"))
pom {
description.set("SARIF data models for Kotlinx serialization")
name.set(rootProject.name)
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
kotlin.code.style=official

GROUP=io.github.detekt.sarif4k
VERSION=0.3.0-SNAPSHOT
VERSION=0.3.0-SNAPSHOT

org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m
TWiStErRob marked this conversation as resolved.
Show resolved Hide resolved
1 change: 0 additions & 1 deletion javadoc-silence.txt

This file was deleted.