Skip to content

Commit

Permalink
Merge pull request #22 from rickclephas/feature/embeddable-compiler
Browse files Browse the repository at this point in the history
Support embeddable compiler jar
  • Loading branch information
rickclephas authored Nov 19, 2021
2 parents 9d85373 + 6a4781a commit 96dc5ea
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/run-integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
xcode: [ 13.1 ]
java: [ 11 ]
platform: [ iOS, macOS, tvOS, watchOS ]
name: ${{ format('{0} ({1}, Xcode {2}, JDK {3})', matrix.platform, matrix.os, matrix.xcode, matrix.java) }}
embeddable-compiler: [ true, false ]
name: ${{ format('{0} (embeddable {1}) ({2}, Xcode {3}, JDK {4})', matrix.platform, matrix.embeddable-compiler, matrix.os, matrix.xcode, matrix.java) }}
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -49,6 +50,10 @@ jobs:
uses: ./.github/actions/cache-gradle
- name: Cache Konan
uses: ./.github/actions/cache-konan
- name: Set kotlin.native.useEmbeddableCompilerJar
env:
KOTLIN_NATIVE_EMBEDDABLE_COMPILER: ${{ matrix.embeddable-compiler }}
run: echo "kotlin.native.useEmbeddableCompilerJar=KOTLIN_NATIVE_EMBEDDABLE_COMPILER" >> gradle.properties
- name: Install CocoaPods dependencies
run: |
./gradlew :shared:generateDummyFramework
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ object Dependencies {
private const val version = "1.6.0"
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version"
const val compiler = "org.jetbrains.kotlin:kotlin-compiler:$version"
const val embeddableCompiler = "org.jetbrains.kotlin:kotlin-compiler-embeddable:$version"
}

object Kotlinx {
Expand Down
1 change: 1 addition & 0 deletions kmp-nativecoroutines-compiler-embeddable/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/
45 changes: 45 additions & 0 deletions kmp-nativecoroutines-compiler-embeddable/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
plugins {
kotlin("jvm")
`kmp-nativecoroutines-publish`
}

dependencies {
compileOnly(Dependencies.Kotlin.embeddableCompiler)
}

val syncSources by tasks.registering(Sync::class) {
from(project(":kmp-nativecoroutines-compiler").sourceSets.main.get().allSource)
into("src/main/kotlin")
filter {
when (it) {
"import com.intellij.mock.MockProject" -> "import org.jetbrains.kotlin.com.intellij.mock.MockProject"
else -> it
}
}
}

tasks.compileKotlin.configure {
dependsOn(syncSources)
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs = listOf("-Xjvm-default=all")
}
}

tasks.clean.configure {
delete("src")
}

val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}

publishing {
publications {
create<MavenPublication>("maven") {
from(components["kotlin"])
artifact(sourcesJar)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ class KmpNativeCoroutinesPlugin: KotlinCompilerPluginSupportPlugin {
SubpluginArtifact("com.rickclephas.kmp", "kmp-nativecoroutines-compiler", VERSION)

override fun getPluginArtifact(): SubpluginArtifact =
throw UnsupportedOperationException("KMP-NativeCoroutines only supports Kotlin\\Native!")
SubpluginArtifact("com.rickclephas.kmp", "kmp-nativecoroutines-compiler-embeddable", VERSION)
}
2 changes: 1 addition & 1 deletion sample/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include(":shared")

includeBuild("..") {
dependencySubstitution {
listOf("annotations", "compiler", "core", "gradle-plugin").forEach {
listOf("annotations", "compiler", "compiler-embeddable", "core", "gradle-plugin").forEach {
substitute(module("com.rickclephas.kmp:kmp-nativecoroutines-$it"))
.using(project(":kmp-nativecoroutines-$it"))
}
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ rootProject.name = "kmp-nativecoroutines"
include(":kmp-nativecoroutines-core")
include(":kmp-nativecoroutines-annotations")
include(":kmp-nativecoroutines-compiler")
include(":kmp-nativecoroutines-compiler-embeddable")
include(":kmp-nativecoroutines-gradle-plugin")

0 comments on commit 96dc5ea

Please sign in to comment.