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
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/merge-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
build:
name: Build project
runs-on: ubuntu-latest
runs-on: macos-latest
TWiStErRob marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
steps:
- name: Checkout Repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main
jobs:
publish:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v2

Expand Down
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
- `gradle.properties` to the next SNAPSHOT version (X.Y.Z)
- `git commit -am "Prepare next development version."`
- `git push && git push --tags`
- Wait for the [publish-release.yml](.github/workflows/publish-release.yml) action to complete.
- Wait for the [publish-snapshot.yml](.github/workflows/publish-snapshot.yml) action to complete.
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 {
implementation("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
7 changes: 6 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
kotlin.code.style=official
# Kotlin Multiplatform Projects are an Alpha feature. See: https://kotlinlang.org/docs/reference/evolution/components-stability.html.
kotlin.mpp.stability.nowarn=true

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

# OOM in Dokka: https://github.com/Kotlin/dokka/issues/1405
org.gradle.jvmargs=-XX:MaxMetaspaceSize=256m
1 change: 0 additions & 1 deletion javadoc-silence.txt

This file was deleted.