1- import io.gitlab.arturbosch.detekt.Detekt
2- import kotlinx.kover.gradle.plugin.dsl.KoverReportExtension
3- import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
4- import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
5- import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin.Companion.kotlinNodeJsExtension
1+ @file:OptIn(ExperimentalKotlinGradlePluginApi ::class )
2+
3+ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
4+ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsPlugin.Companion.kotlinNodeJsEnvSpec
65import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn
76import java.util.*
87
98plugins {
10- val kotlinVersion = " 2.0.20-Beta1"
11- kotlin(" multiplatform" ) version kotlinVersion
12- // id("dev.petuska.npm.publish") version "2.1.1"
13- id(" io.gitlab.arturbosch.detekt" ).version(" 1.23.0-RC2" )
14- id(" org.jetbrains.dokka" ) version " 1.9.0"
15- id(" org.jetbrains.kotlinx.kover" ) version " 0.7.3"
9+ alias(libs.plugins.kotlin.multiplatform)
10+ alias(libs.plugins.detekt)
11+ alias(libs.plugins.dokka)
12+ alias(libs.plugins.kover)
1613 id(" maven-publish" )
1714 id(" signing" )
1815}
1916
2017val defaultGroupId = " cz.sazel.sqldelight"
21- val versionBase = " 0.3 .0"
18+ val versionBase = " 0.4 .0"
2219
2320val localProperties = Properties ().apply {
2421 try {
@@ -58,6 +55,7 @@ kotlin {
5855
5956 useCommonJs()
6057 nodejs {
58+ version = libs.versions.node.js.get()
6159 testTask {
6260 // debug=true
6361 }
@@ -88,25 +86,25 @@ kotlin {
8886 }
8987 }
9088 val jsTest by getting {
91- extensions.configure<KoverReportExtension > {
92- defaults {
93- html {
94- onCheck = true
95- }
96- }
97- }
89+
9890 }
9991
10092 val publicationsFromMainHost =
10193 listOf (js()).map { it.name } + " kotlinMultiplatform"
10294
103- val javadocJar = tasks.register<Jar >(" javadocJar" ) {
104- dependsOn(tasks.dokkaHtml)
105- archiveClassifier.set(" javadoc" )
106- from(" $buildDir /dokka" )
95+ dokka {
96+ moduleName = " node-sqlite3-driver"
97+ moduleVersion = versionStr
98+
99+ dokkaSourceSets {
100+ val jsMain by getting {
101+
102+ }
103+ }
107104 }
108105
109106 publishing {
107+
110108 publications {
111109 matching { it.name in publicationsFromMainHost }.all {
112110 val targetPublication = this @all
@@ -117,7 +115,7 @@ kotlin {
117115
118116
119117 withType<MavenPublication > {
120- artifact(javadocJar )
118+ artifact(layout.buildDirectory.dir( " dokka " ) )
121119
122120 pom {
123121 name.set(" node-sqlite3-driver" )
@@ -176,7 +174,7 @@ kotlin {
176174 }
177175 }
178176
179- extensions.configure< SigningExtension > {
177+ signing {
180178 useInMemoryPgpKeys(
181179 System .getenv(" GPG_KEY_SECRET" ) ? : localProperties[" gpg.keySecret" ] as String? ,
182180 System .getenv(" GPG_KEY_PASSWORD" ) ? : localProperties[" gpg.keyPassword" ] as String?
@@ -185,28 +183,6 @@ kotlin {
185183 sign(publishing.publications)
186184 }
187185 }
188-
189-
190-
191- plugins.withType<NodeJsRootPlugin > {
192- configure<NodeJsRootExtension > {
193- version = " 18.14.2"
194- }
195- }
196-
197- // npmPublishing {
198- // organization = "wojta"
199- // access = RESTRICTED
200- //
201- // repositories {
202- // repository("npmjs") {
203- // registry = uri("https://npm.pkg.github.com") // Registry to publish to
204- // authToken = localProperties["github.token"] as String?
205- // ?: System.getenv("GITHUB_TOKEN")// NPM registry authentication token
206- // }
207- // }
208- // }
209-
210186}
211187
212188// workaround for missing sqlite3 bindings
@@ -215,18 +191,17 @@ val bindingsInstall = tasks.register("sqlite3BindingsInstall") {
215191
216192 }
217193 doLast {
218- val sqlite3moduleDir = buildDir.resolve( " js/node_modules/sqlite3" )
219- if (! sqlite3moduleDir.resolve(" lib/binding " ).exists()) {
194+ val sqlite3moduleDir = layout.buildDirectory.get().dir( " js/node_modules/sqlite3" ).asFile
195+ if (! sqlite3moduleDir.resolve(" build " ).exists()) {
220196 exec {
221197 workingDir = sqlite3moduleDir
222- val yarnPath= " ${yarn.yarnSetupTaskProvider.get().destination.absolutePath} /bin"
223- val nodePath= " ${kotlinNodeJsExtension.nodeJsSetupTaskProvider.get().destination.absolutePath} /bin"
198+ val yarnExecutable = yarn.environment.executable
199+ val yarnPath = file(yarnExecutable).parent
200+ val nodePath = file(kotlinNodeJsEnvSpec.executable).parent
224201 environment(
225- " PATH" ,
226- System .getenv(" PATH" ) + " :$yarnPath :$nodePath "
202+ " PATH" , System .getenv(" PATH" ) + " :$yarnPath :$nodePath "
227203 )
228- var commandLine = " $yarnPath /yarn"
229- commandLine(commandLine)
204+ commandLine(yarnExecutable)
230205 }
231206 }
232207 }
@@ -238,10 +213,9 @@ detekt {
238213 allRules = false // activate all available (even unstable) rules.
239214 config.setFrom(" $projectDir /gradle/detekt/detekt.yml" ) // point to your custom config defining rules to run, overwriting default behavior
240215 // baseline = file("$projectDir/config/baseline.xml") // a way of suppressing issues before introducing detekt
241- }
242216
243- tasks.withType<Detekt >().configureEach {
244217 reports {
245218 html.required.set(true ) // observe findings in your browser with structure and code snippets
246219 }
247220}
221+
0 commit comments