@@ -17,117 +17,109 @@ import org.gradle.jvm.toolchain.JavaLanguageVersion
1717import org.gradle.kotlin.dsl.configure
1818import org.gradle.kotlin.dsl.get
1919import org.gradle.kotlin.dsl.withType
20- import org.jetbrains.dokka.gradle.DokkaPlugin
2120import org.jetbrains.dokka.gradle.DokkaTask
2221import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
2322import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
24- import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
2523
2624class KotlinMultiplatformConventionPlugin : Plugin <Project > {
27- override fun apply (project : Project ) = with (project) {
28-
29-
30- with (pluginManager) {
31- apply (" org.jetbrains.kotlin.multiplatform" )
32- apply (" org.jetbrains.kotlin.plugin.serialization" )
33- apply (" com.android.library" )
34- apply (" com.vanniktech.maven.publish" )
35- apply (" org.jetbrains.dokka" )
36- apply (" org.jetbrains.kotlinx.kover" )
37- apply (" co.touchlab.faktory.kmmbridge" )
38- apply (" maven-publish" )
39- apply (" org.jetbrains.kotlin.native.cocoapods" )
40- apply (" kotlinx-atomicfu" )
41- apply (" org.jetbrains.kotlinx.binary-compatibility-validator" )
42- }
43-
44-
45- extensions.configure<KotlinMultiplatformExtension > {
25+ override fun apply (project : Project ) =
26+ with (project) {
27+ with (pluginManager) {
28+ apply (" org.jetbrains.kotlin.multiplatform" )
29+ apply (" org.jetbrains.kotlin.plugin.serialization" )
30+ apply (" com.android.library" )
31+ apply (" com.vanniktech.maven.publish" )
32+ apply (" org.jetbrains.dokka" )
33+ apply (" org.jetbrains.kotlinx.kover" )
34+ apply (" co.touchlab.faktory.kmmbridge" )
35+ apply (" maven-publish" )
36+ apply (" org.jetbrains.kotlin.native.cocoapods" )
37+ apply (" kotlinx-atomicfu" )
38+ apply (" org.jetbrains.kotlinx.binary-compatibility-validator" )
39+ }
4640
47- applyDefaultHierarchyTemplate()
41+ extensions.configure<KotlinMultiplatformExtension > {
42+ applyDefaultHierarchyTemplate()
4843
49- androidTarget()
44+ androidTarget()
5045
51- jvm()
46+ jvm()
5247
53- iosX64()
54- iosArm64()
55- iosSimulatorArm64()
48+ iosX64()
49+ iosArm64()
50+ iosSimulatorArm64()
5651
57- linuxX64()
52+ linuxX64()
5853
59- js {
60- browser()
61- nodejs()
62- }
54+ js {
55+ browser()
56+ nodejs()
57+ }
6358
64- jvmToolchain(11 )
59+ jvmToolchain(11 )
6560
66- targets.all {
67- compilations.all {
68- compilerOptions.configure {
69- freeCompilerArgs.add(" -Xexpect-actual-classes" )
61+ targets.all {
62+ compilations.all {
63+ compilerOptions.configure {
64+ freeCompilerArgs.add(" -Xexpect-actual-classes" )
65+ }
7066 }
7167 }
72- }
7368
74- targets.withType<KotlinNativeTarget >().configureEach {
75- compilations.configureEach {
76- compilerOptions.configure {
77- freeCompilerArgs.add(" -Xallocator=custom" )
78- freeCompilerArgs.add(" -XXLanguage:+ImplicitSignedToUnsignedIntegerConversion" )
79- freeCompilerArgs.add(" -Xadd-light-debug=enable" )
80-
81- freeCompilerArgs.addAll(
82- " -opt-in=kotlin.RequiresOptIn" ,
83- " -opt-in=kotlin.time.ExperimentalTime" ,
84- " -opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi" ,
85- " -opt-in=kotlinx.coroutines.FlowPreview" ,
86- " -opt-in=kotlinx.cinterop.ExperimentalForeignApi" ,
87- " -opt-in=kotlinx.cinterop.BetaInteropApi" ,
88- )
69+ targets.withType<KotlinNativeTarget >().configureEach {
70+ compilations.configureEach {
71+ compilerOptions.configure {
72+ freeCompilerArgs.add(" -Xallocator=custom" )
73+ freeCompilerArgs.add(" -XXLanguage:+ImplicitSignedToUnsignedIntegerConversion" )
74+ freeCompilerArgs.add(" -Xadd-light-debug=enable" )
75+
76+ freeCompilerArgs.addAll(
77+ " -opt-in=kotlin.RequiresOptIn" ,
78+ " -opt-in=kotlin.time.ExperimentalTime" ,
79+ " -opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi" ,
80+ " -opt-in=kotlinx.coroutines.FlowPreview" ,
81+ " -opt-in=kotlinx.cinterop.ExperimentalForeignApi" ,
82+ " -opt-in=kotlinx.cinterop.BetaInteropApi" ,
83+ )
84+ }
8985 }
9086 }
91- }
9287
93- sourceSets.all {
94- languageSettings.apply {
95- optIn(" kotlin.contracts.ExperimentalContracts" )
96- optIn(" kotlinx.coroutines.ExperimentalCoroutinesApi" )
97- optIn(" kotlin.RequiresOptIn" )
88+ sourceSets.all {
89+ languageSettings.apply {
90+ optIn(" kotlin.contracts.ExperimentalContracts" )
91+ optIn(" kotlinx.coroutines.ExperimentalCoroutinesApi" )
92+ optIn(" kotlin.RequiresOptIn" )
93+ }
9894 }
99- }
10095
101- sourceSets.getByName(" commonTest" ) {
102- dependencies {
103- implementation(kotlin(" test" ))
96+ sourceSets.getByName(" commonTest" ) {
97+ dependencies {
98+ implementation(kotlin(" test" ))
99+ }
104100 }
105- }
106101
107- sourceSets.getByName(" jvmTest" ) {
108- dependencies {
109- implementation(kotlin(" test-junit" ))
102+ sourceSets.getByName(" jvmTest" ) {
103+ dependencies {
104+ implementation(kotlin(" test-junit" ))
105+ }
110106 }
111- }
112107
113- sourceSets.getByName(" nativeMain" ) {
114- dependsOn(sourceSets.getByName(" commonMain" ))
108+ sourceSets.getByName(" nativeMain" ) {
109+ dependsOn(sourceSets.getByName(" commonMain" ))
110+ }
115111 }
116112
117-
113+ configureKotlin()
114+ configureAndroid()
115+ configureDokka()
116+ configureMavenPublishing()
117+ addGithubPackagesRepository()
118+ configureKmmBridge()
119+ configureAtomicFu()
118120 }
119-
120- configureKotlin()
121- configureAndroid()
122- configureDokka()
123- configureMavenPublishing()
124- addGithubPackagesRepository()
125- configureKmmBridge()
126- configureAtomicFu()
127- }
128121}
129122
130-
131123fun Project.configureKotlin () {
132124 configureJava()
133125}
@@ -162,65 +154,64 @@ fun Project.configureAndroid() {
162154 }
163155}
164156
165-
166157fun Project.android (action : LibraryExtension .() -> Unit ) = extensions.configure<LibraryExtension >(action)
167158
168159private fun Project.java (action : JavaPluginExtension .() -> Unit ) = extensions.configure<JavaPluginExtension >(action)
169160
170-
171161object Versions {
172162 const val COMPILE_SDK = 34
173163 const val MIN_SDK = 24
174164 const val TARGET_SDK = 34
175- const val STORE = " 5.1.0-alpha05"
176- }
177-
178-
179- fun Project.configureMavenPublishing () = extensions.configure<MavenPublishBaseExtension > {
180- publishToMavenCentral(S01 )
181- signAllPublications()
165+ const val STORE = " 5.1.0-SNAPSHOT"
182166}
183167
168+ fun Project.configureMavenPublishing () =
169+ extensions.configure<MavenPublishBaseExtension > {
170+ publishToMavenCentral(S01 )
171+ signAllPublications()
172+ }
184173
185- fun Project.configureKmmBridge () = extensions.configure<KmmBridgeExtension > {
186- githubReleaseArtifacts()
187- githubReleaseVersions()
188- versionPrefix.set(Versions .STORE )
189- spm()
190- }
174+ fun Project.configureKmmBridge () =
175+ extensions.configure<KmmBridgeExtension > {
176+ githubReleaseArtifacts()
177+ githubReleaseVersions()
178+ versionPrefix.set(Versions .STORE )
179+ spm()
180+ }
191181
192- fun Project.configureKover () = extensions.configure<KoverMergedConfig > {
193- enable()
182+ fun Project.configureKover () =
183+ extensions.configure<KoverMergedConfig > {
184+ enable()
194185
195- xmlReport {
196- onCheck.set(true )
197- reportFile.set(layout.projectDirectory.file(" kover/coverage.xml" ))
198- }
186+ xmlReport {
187+ onCheck.set(true )
188+ reportFile.set(layout.projectDirectory.file(" kover/coverage.xml" ))
189+ }
199190
200- htmlReport {
201- onCheck.set(true )
202- reportDir.set(layout.projectDirectory.dir(" kover/html" ))
203- }
191+ htmlReport {
192+ onCheck.set(true )
193+ reportDir.set(layout.projectDirectory.dir(" kover/html" ))
194+ }
204195
205- verify {
206- onCheck.set(true )
196+ verify {
197+ onCheck.set(true )
198+ }
207199 }
208- }
209-
210200
211201fun Project.configureAtomicFu () =
212202 extensions.configure<AtomicFUPluginExtension > {
213203 transformJvm = false
214204 transformJs = false
215205 }
216206
217- fun Project.configureDokka () = tasks.withType<DokkaTask >().configureEach {
218- dokkaSourceSets.configureEach {
219- reportUndocumented.set(false )
220- skipDeprecated.set(true )
221- jdkVersion.set(11 )
207+ fun Project.configureDokka () =
208+ tasks.withType<DokkaTask >().configureEach {
209+ dokkaSourceSets.configureEach {
210+ reportUndocumented.set(false )
211+ skipDeprecated.set(true )
212+ jdkVersion.set(11 )
213+ }
222214 }
223- }
224215
225216fun Project.android (name : String ) {
226217 android {
0 commit comments