diff --git a/build.gradle.kts b/build.gradle.kts index d8c6a93a..8494144e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ -val dataforgeVersion by extra("0.1.2-dev-7") +val dataforgeVersion by extra("0.1.2") allprojects { repositories { @@ -12,7 +12,7 @@ allprojects { subprojects { if (name.startsWith("dataforge")) { - apply(plugin = "bintray-config") - apply(plugin = "artifactory-config") + apply(plugin = "npm-bintray") + apply(plugin = "npm-artifactory") } } \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 7accd39e..1ebbdf4d 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -14,6 +14,7 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.5") implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4") + implementation("org.jetbrains.dokka:dokka-gradle-plugin:0.9.18") implementation("com.moowork.gradle:gradle-node-plugin:1.3.1") implementation("org.openjfx:javafx-plugin:0.0.7") } diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index f09472ba..883af120 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -5,6 +5,5 @@ object Versions { val ioVersion = "0.1.8" val coroutinesVersion = "1.2.1" val atomicfuVersion = "0.12.6" - val dokkaVersion = "0.9.18" val serializationVersion = "0.11.0" } diff --git a/buildSrc/src/main/kotlin/dokka-publish.gradle.kts b/buildSrc/src/main/kotlin/dokka-publish.gradle.kts new file mode 100644 index 00000000..318e08ae --- /dev/null +++ b/buildSrc/src/main/kotlin/dokka-publish.gradle.kts @@ -0,0 +1,59 @@ +import org.jetbrains.dokka.gradle.DokkaTask + +plugins { + kotlin("multiplatform") + id("org.jetbrains.dokka") + `maven-publish` +} + +kotlin { + + val dokka by tasks.getting(DokkaTask::class) { + outputFormat = "html" + outputDirectory = "$buildDir/javadoc" + jdkVersion = 8 + + kotlinTasks { + // dokka fails to retrieve sources from MPP-tasks so we only define the jvm task + listOf(tasks.getByPath("compileKotlinJvm")) + } + sourceRoot { + // assuming only single source dir + path = sourceSets["commonMain"].kotlin.srcDirs.first().toString() + platforms = listOf("Common") + } + // although the JVM sources are now taken from the task, + // we still define the jvm source root to get the JVM marker in the generated html + sourceRoot { + // assuming only single source dir + path = sourceSets["jvmMain"].kotlin.srcDirs.first().toString() + platforms = listOf("JVM") + } + } + + val javadocJar by tasks.registering(Jar::class) { + dependsOn(dokka) + archiveClassifier.set("javadoc") + from("$buildDir/javadoc") + } + + publishing { + + // publications.filterIsInstance().forEach { publication -> +// if (publication.name == "kotlinMultiplatform") { +// // for our root metadata publication, set artifactId with a package and project name +// publication.artifactId = project.name +// } else { +// // for targets, set artifactId with a package, project name and target name (e.g. iosX64) +// publication.artifactId = "${project.name}-${publication.name}" +// } +// } + + targets.all { + val publication = publications.findByName(name) as MavenPublication + + // Patch publications with fake javadoc + publication.artifact(javadocJar.get()) + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/artifactory-config.gradle.kts b/buildSrc/src/main/kotlin/npm-artifactory.gradle.kts similarity index 100% rename from buildSrc/src/main/kotlin/artifactory-config.gradle.kts rename to buildSrc/src/main/kotlin/npm-artifactory.gradle.kts diff --git a/buildSrc/src/main/kotlin/bintray-config.gradle.kts b/buildSrc/src/main/kotlin/npm-bintray.gradle.kts similarity index 100% rename from buildSrc/src/main/kotlin/bintray-config.gradle.kts rename to buildSrc/src/main/kotlin/npm-bintray.gradle.kts diff --git a/buildSrc/src/main/kotlin/multiplatform-config.gradle.kts b/buildSrc/src/main/kotlin/npm-multiplatform.gradle.kts similarity index 53% rename from buildSrc/src/main/kotlin/multiplatform-config.gradle.kts rename to buildSrc/src/main/kotlin/npm-multiplatform.gradle.kts index 41fa58f4..671986b8 100644 --- a/buildSrc/src/main/kotlin/multiplatform-config.gradle.kts +++ b/buildSrc/src/main/kotlin/npm-multiplatform.gradle.kts @@ -1,4 +1,3 @@ -import gradle.kotlin.dsl.plugins._e2353938d1a2b15c365d69a8d533ab12.js import org.gradle.kotlin.dsl.* plugins { @@ -33,35 +32,35 @@ kotlin { } } - sourceSets.invoke { - commonMain { + sourceSets { + val commonMain by getting { dependencies { api(kotlin("stdlib")) } } - commonTest { + val commonTest by getting { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) } } - "jvmMain" { + val jvmMain by getting { dependencies { api(kotlin("stdlib-jdk8")) } } - "jvmTest" { + val jvmTest by getting { dependencies { implementation(kotlin("test")) implementation(kotlin("test-junit")) } } - "jsMain" { + val jsMain by getting { dependencies { api(kotlin("stdlib-js")) } } - "jsTest" { + val jsTest by getting { dependencies { implementation(kotlin("test-js")) } @@ -75,37 +74,7 @@ kotlin { } } - // Create empty jar for sources classifier to satisfy maven requirements - val stubSources by tasks.registering(Jar::class){ - archiveClassifier.set("sources") - //from(sourceSets.main.get().allSource) - } - - // Create empty jar for javadoc classifier to satisfy maven requirements - val stubJavadoc by tasks.registering(Jar::class) { - archiveClassifier.set("javadoc") - } - - - publishing { - - publications.filterIsInstance().forEach { publication -> - if (publication.name == "kotlinMultiplatform") { - // for our root metadata publication, set artifactId with a package and project name - publication.artifactId = project.name - } else { - // for targets, set artifactId with a package, project name and target name (e.g. iosX64) - publication.artifactId = "${project.name}-${publication.name}" - } - } - - targets.all { - val publication = publications.findByName(name) as MavenPublication - - // Patch publications with fake javadoc - publication.artifact(stubJavadoc.get()) - } - } + apply(plugin = "dokka-publish") // Apply JS test configuration val runJsTests by ext(false) diff --git a/dataforge-context/build.gradle.kts b/dataforge-context/build.gradle.kts index d91d3197..f454e2ef 100644 --- a/dataforge-context/build.gradle.kts +++ b/dataforge-context/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - `multiplatform-config` + `npm-multiplatform` } description = "Context and provider definitions" diff --git a/dataforge-data/build.gradle.kts b/dataforge-data/build.gradle.kts index 97cb7143..7ebb46ce 100644 --- a/dataforge-data/build.gradle.kts +++ b/dataforge-data/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - `multiplatform-config` + `npm-multiplatform` } val coroutinesVersion: String = Versions.coroutinesVersion diff --git a/dataforge-io/build.gradle.kts b/dataforge-io/build.gradle.kts index 4104e1c4..67ffe124 100644 --- a/dataforge-io/build.gradle.kts +++ b/dataforge-io/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - `multiplatform-config` + `npm-multiplatform` } description = "IO for meta" diff --git a/dataforge-meta/build.gradle.kts b/dataforge-meta/build.gradle.kts index 37aa617e..17aaebf8 100644 --- a/dataforge-meta/build.gradle.kts +++ b/dataforge-meta/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - `multiplatform-config` + `npm-multiplatform` } description = "Meta definition and basic operations on meta" diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt index 8b439a98..e848ec31 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt @@ -17,10 +17,10 @@ fun Configurable.value(default: T? = null, key: String? = null, transform: ( MutableValueDelegate(config, key, Value.of(default)).transform(reader = transform) fun Configurable.stringList(key: String? = null) = - value { it?.list?.map { value -> value.string } ?: emptyList() } + value(key) { it?.list?.map { value -> value.string } ?: emptyList() } fun Configurable.numberList(key: String? = null) = - value { it?.list?.map { value -> value.number } ?: emptyList() } + value(key) { it?.list?.map { value -> value.number } ?: emptyList() } fun Configurable.string(default: String? = null, key: String? = null) = MutableStringDelegate(config, key, default) diff --git a/dataforge-output/build.gradle.kts b/dataforge-output/build.gradle.kts index 6df39417..36811267 100644 --- a/dataforge-output/build.gradle.kts +++ b/dataforge-output/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - `multiplatform-config` + `npm-multiplatform` } kotlin { diff --git a/dataforge-output/dataforge-output-html/build.gradle.kts b/dataforge-output/dataforge-output-html/build.gradle.kts index 292ed0ca..d1693bab 100644 --- a/dataforge-output/dataforge-output-html/build.gradle.kts +++ b/dataforge-output/dataforge-output-html/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - `multiplatform-config` + `npm-multiplatform` } val htmlVersion by rootProject.extra("0.6.12") diff --git a/dataforge-scripting/build.gradle.kts b/dataforge-scripting/build.gradle.kts index a1a65f97..eb8f7742 100644 --- a/dataforge-scripting/build.gradle.kts +++ b/dataforge-scripting/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - `multiplatform-config` + `npm-multiplatform` } kotlin { diff --git a/dataforge-workspace/build.gradle.kts b/dataforge-workspace/build.gradle.kts index 8f5004b7..e6aa9dd0 100644 --- a/dataforge-workspace/build.gradle.kts +++ b/dataforge-workspace/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - `multiplatform-config` + `npm-multiplatform` } kotlin {