Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit cc35a07

Browse files
committed
Add Kotlin/Native specific plugin
1 parent 0b03187 commit cc35a07

File tree

4 files changed

+129
-1
lines changed

4 files changed

+129
-1
lines changed

kotlin-power-assert-gradle/src/main/kotlin/com/bnorm/power/PowerAssertGradlePlugin.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ class PowerAssertGradlePlugin : KotlinCompilerPluginSupportPlugin {
3434

3535
override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact(
3636
groupId = "com.bnorm.power",
37-
artifactId = "kotlin-power-assert",
37+
artifactId = "kotlin-power-assert-plugin",
38+
version = "0.5.0-SNAPSHOT"
39+
)
40+
41+
override fun getPluginArtifactForNative(): SubpluginArtifact = SubpluginArtifact(
42+
groupId = "com.bnorm.power",
43+
artifactId = "kotlin-power-assert-plugin-native",
3844
version = "0.5.0-SNAPSHOT"
3945
)
4046

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
plugins {
4+
kotlin("jvm")
5+
kotlin("kapt")
6+
id("org.jetbrains.dokka")
7+
8+
signing
9+
`maven-publish`
10+
}
11+
12+
dependencies {
13+
compileOnly("org.jetbrains.kotlin:kotlin-compiler")
14+
15+
kapt("com.google.auto.service:auto-service:1.0-rc6")
16+
compileOnly("com.google.auto.service:auto-service-annotations:1.0-rc6")
17+
}
18+
19+
tasks.named("compileKotlin") { dependsOn("syncSource") }
20+
tasks.register<Sync>("syncSource") {
21+
from(project(":kotlin-power-assert-plugin").sourceSets.main.get().allSource)
22+
into("src/main/kotlin")
23+
filter {
24+
// Replace shadowed imports from kotlin-power-assert-plugin
25+
when (it) {
26+
"import org.jetbrains.kotlin.com.intellij.mock.MockProject" -> "import com.intellij.mock.MockProject"
27+
else -> it
28+
}
29+
}
30+
}
31+
32+
tasks.withType<KotlinCompile> {
33+
kotlinOptions.jvmTarget = "1.8"
34+
}
35+
36+
tasks.dokka {
37+
outputFormat = "html"
38+
outputDirectory = "$buildDir/javadoc"
39+
}
40+
41+
tasks.register("sourcesJar", Jar::class) {
42+
group = "build"
43+
description = "Assembles Kotlin sources"
44+
45+
archiveClassifier.set("sources")
46+
from(sourceSets.main.get().allSource)
47+
dependsOn(tasks.classes)
48+
}
49+
50+
tasks.register("dokkaJar", Jar::class) {
51+
group = "documentation"
52+
description = "Assembles Kotlin docs with Dokka"
53+
54+
archiveClassifier.set("javadoc")
55+
from(tasks.dokka)
56+
dependsOn(tasks.dokka)
57+
}
58+
59+
signing {
60+
setRequired(provider { gradle.taskGraph.hasTask("publish") })
61+
sign(publishing.publications)
62+
}
63+
64+
publishing {
65+
publications {
66+
create<MavenPublication>("default") {
67+
from(components["java"])
68+
artifact(tasks["sourcesJar"])
69+
artifact(tasks["dokkaJar"])
70+
71+
pom {
72+
name.set(project.name)
73+
description.set("Kotlin compiler plugin to enable power assertions in the Kotlin programming language")
74+
url.set("https://github.com/bnorm/kotlin-power-assert")
75+
76+
licenses {
77+
license {
78+
name.set("Apache License 2.0")
79+
url.set("https://github.com/bnorm/kotlin-power-assert/blob/master/LICENSE.txt")
80+
}
81+
}
82+
scm {
83+
url.set("https://github.com/bnorm/kotlin-power-assert")
84+
connection.set("scm:git:git://github.com/bnorm/kotlin-power-assert.git")
85+
}
86+
developers {
87+
developer {
88+
name.set("Brian Norman")
89+
url.set("https://github.com/bnorm")
90+
}
91+
}
92+
}
93+
}
94+
}
95+
96+
repositories {
97+
if (
98+
hasProperty("sonatypeUsername") &&
99+
hasProperty("sonatypePassword") &&
100+
hasProperty("sonatypeSnapshotUrl") &&
101+
hasProperty("sonatypeReleaseUrl")
102+
) {
103+
maven {
104+
val url = when {
105+
"SNAPSHOT" in version.toString() -> property("sonatypeSnapshotUrl")
106+
else -> property("sonatypeReleaseUrl")
107+
} as String
108+
setUrl(url)
109+
credentials {
110+
username = property("sonatypeUsername") as String
111+
password = property("sonatypePassword") as String
112+
}
113+
}
114+
}
115+
maven {
116+
name = "test"
117+
setUrl("file://${rootProject.buildDir}/localMaven")
118+
}
119+
}
120+
}

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ rootProject.name = "kotlin-power-assert"
22

33
include(":kotlin-power-assert-gradle")
44
include(":kotlin-power-assert-plugin")
5+
include(":kotlin-power-assert-plugin-native")

0 commit comments

Comments
 (0)