1+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
2+
13plugins {
2- id(" java-library" )
3- id(" maven-publish" )
4- alias(libs.plugins.kotlin.jvm)
4+ alias(libs.plugins.kotlin.multiplatform)
55 alias(libs.plugins.dokka)
66 alias(libs.plugins.ksp)
7- signing
7+ alias(libs.plugins.mavenPublish)
88}
99
10+ val nvplibVersion: String? by project
11+ group = " net.cacheux.nvplib"
12+ version = nvplibVersion ? : " unknown"
13+
1014kotlin {
11- jvmToolchain(libs.versions.java.get().toInt())
12- }
15+ jvmToolchain(libs.versions.nvplibJava.get().toInt())
16+
17+ jvm()
18+
19+ val xcfName = " bytonioKit"
20+
21+ iosX64 {
22+ binaries.framework {
23+ baseName = xcfName
24+ }
25+ }
1326
14- java {
15- withSourcesJar()
27+ iosArm64 {
28+ binaries.framework {
29+ baseName = xcfName
30+ }
31+ }
32+
33+ iosSimulatorArm64 {
34+ binaries.framework {
35+ baseName = xcfName
36+ }
37+ }
38+
39+ sourceSets {
40+ commonMain {
41+ kotlin.srcDir(" build/generated/ksp/metadata/commonMain/kotlin" )
42+ dependencies {
43+ api(libs.bytonio.core)
44+ }
45+ }
46+
47+ jvmTest {
48+ dependencies {
49+ implementation(libs.junit)
50+ implementation(project(" :nvplib:testing" ))
51+ implementation(project(" :utils" ))
52+ }
53+ }
54+ }
1655}
1756
1857ksp {
@@ -21,79 +60,47 @@ ksp {
2160}
2261
2362dependencies {
24- api(libs.bytonio.core)
25- ksp(libs.bytonio.processor)
26-
27- testImplementation(libs.junit)
28- testImplementation(project(" :nvplib:testing" ))
29- testImplementation(project(" :utils" ))
63+ add(" kspCommonMainMetadata" , libs.bytonio.processor)
3064}
3165
32- tasks.register<Jar >(" dokkaHtmlJar" ) {
33- dependsOn(tasks.dokkaHtml)
34- from(tasks.dokkaHtml.flatMap { it.outputDirectory })
35- archiveClassifier.set(" html-docs" )
36- }
66+ mavenPublishing {
67+ publishToMavenCentral()
3768
38- tasks.register<Jar >(" dokkaJavadocJar" ) {
39- dependsOn(tasks.dokkaJavadoc)
40- from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
41- archiveClassifier.set(" javadoc" )
42- }
69+ signAllPublications()
4370
44- publishing {
45- repositories {
46- maven {
47- url = uri(layout.buildDirectory.dir(" release" ))
48- }
49- }
71+ coordinates(group.toString(), " nvplib-core" , version.toString())
5072
51- publications {
52- create<MavenPublication >(" mavenCore" ) {
53- groupId = " net.cacheux.nvplib"
54- artifactId = " nvplib-core"
55- version = " 0.1.2"
56- afterEvaluate {
57- from(components[" java" ])
58- artifact(tasks[" dokkaHtmlJar" ])
59- artifact(tasks[" dokkaJavadocJar" ])
73+ pom {
74+ name = " NVP Lib Core"
75+ description = " Core library to read data from Novopen insulin pens"
76+ url = " https://github.com/lcacheux/nov-open-reader"
77+ licenses {
78+ license {
79+ name = " The Apache License, Version 2.0"
80+ url = " https://www.apache.org/licenses/LICENSE-2.0.txt"
6081 }
61-
62- pom {
63- name = " NVP Lib Core"
64- description = " Core library to read data from Novopen insulin pens"
65- url = " https://github.com/lcacheux/nov-open-reader"
66- licenses {
67- license {
68- name = " The Apache License, Version 2.0"
69- url = " https://www.apache.org/licenses/LICENSE-2.0.txt"
70- }
71- }
72- developers {
73- developer {
74- id = " lcacheux"
75- name = " Leo Cacheux"
76- email = " leo@cacheux.net"
77- }
78- }
79- scm {
80- connection = " scm:git:https://github.com/lcacheux/nov-open-reader.git"
81- developerConnection = " scm:git:ssh://github.com/lcacheux/nov-open-reader.git"
82- url = " https://github.com/lcacheux/nov-open-reader"
83- }
82+ }
83+ developers {
84+ developer {
85+ id = " lcacheux"
86+ name = " Leo Cacheux"
87+ email = " leo@cacheux.net"
8488 }
8589 }
90+ scm {
91+ connection = " scm:git:https://github.com/lcacheux/nov-open-reader.git"
92+ developerConnection = " scm:git:ssh://github.com/lcacheux/nov-open-reader.git"
93+ url = " https://github.com/lcacheux/nov-open-reader"
94+ }
8695 }
8796}
8897
89- val signingIfAvailable: (Publication ) -> Unit by project
90- signingIfAvailable(publishing.publications.getByName(" mavenCore" ))
91-
92- tasks.create<Zip >(" bundleZip" ) {
93- dependsOn(" publish" )
94- from(layout.buildDirectory.dir(" release" ).get()) {
95- exclude(" **/*.asc.*" )
98+ afterEvaluate {
99+ tasks.withType(KotlinCompilationTask ::class ).configureEach {
100+ if (name != " kspCommonMainKotlinMetadata" ) {
101+ dependsOn(" kspCommonMainKotlinMetadata" )
102+ }
96103 }
97- archiveFileName = " nvplib-core.zip"
98- destinationDirectory = layout.buildDirectory.dir(" bundle" ).get()
104+ tasks.findByName(" sourcesJar" )?.dependsOn(" kspCommonMainKotlinMetadata" )
99105}
106+
0 commit comments