diff --git a/build.gradle.kts b/build.gradle.kts index eae2335..81ba62c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,14 @@ import java.util.* plugins { + `java-gradle-plugin` `kotlin-dsl` `maven-publish` - id("com.jfrog.bintray") version "1.8.5" id("org.jetbrains.changelog") version "0.4.0" } group = "ru.mipt.npm" -version = "0.6.0-dev-1" +version = "0.6.0-dev-3" repositories { gradlePluginPortal() @@ -28,44 +28,44 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion") implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.14.4") - implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.0-rc") - implementation("org.jetbrains.dokka:dokka-core:1.4.0-rc") + implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.0") + implementation("org.jetbrains.dokka:dokka-core:1.4.0") } gradlePlugin { plugins { - create("kscience-publish") { - id = "kscience.publish" + create("kscience.publish") { + id = "ru.mipt.npm.publish" description = "The publication plugin for bintray and github" implementationClass = "ru.mipt.npm.gradle.KSciencePublishPlugin" } create("kscience.mpp") { - id = "kscience.mpp" + id = "ru.mipt.npm.mpp" description = "Pre-configured multiplatform project" implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin" } create("kscience.jvm") { - id = "kscience.jvm" + id = "ru.mipt.npm.jvm" description = "Pre-configured JVM project" implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin" } create("kscience.js") { - id = "kscience.js" + id = "ru.mipt.npm.js" description = "Pre-configured JS project" implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin" } create("kscience.native") { - id = "kscience.native" + id = "ru.mipt.npm.native" description = "Additional native targets to be use alongside mpp" implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin" } create("kscience.node") { - id = "kscience.node" + id = "ru.mipt.npm.node" description = "NodeJS target for kotlin-mpp and kotlin-js" implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin" } @@ -74,7 +74,7 @@ gradlePlugin { publishing { repositories { - maven("https://bintray.com/mipt-npm/scientifik") + maven("https://bintray.com/mipt-npm/kscience") } val vcs = "https://github.com/mipt-npm/scientifik-gradle-tools" @@ -105,38 +105,67 @@ publishing { } scm { url.set(vcs) + tag.set(project.version.toString()) } } } - bintray { - user = project.findProperty("bintrayUser") as? String ?: System.getenv("BINTRAY_USER") - key = project.findProperty("bintrayApiKey") as? String? ?: System.getenv("BINTRAY_API_KEY") - publish = true - override = true // for multi-platform Kotlin/Native publishing + val bintrayUser: String? by project + val bintrayApiKey: String? by project - // We have to use delegateClosureOf because bintray supports only dynamic groovy syntax - // this is a problem of this plugin - pkg.apply { - userOrg = "mipt-npm" - repo = if (project.version.toString().contains("dev")) "dev" else "kscience" - name = project.name - issueTrackerUrl = "$vcs/issues" - setLicenses("Apache-2.0") - vcsUrl = vcs - version.apply { - name = project.version.toString() - vcsTag = project.version.toString() - released = Date().toString() + val bintrayRepo = if (project.version.toString().contains("dev")) { + "dev" + } else { + findProperty("bintrayRepo") as? String + } + + val projectName = project.name + + if (bintrayRepo != null && bintrayUser != null && bintrayApiKey != null) { + repositories { + maven { + name = "bintray" + url = uri( + "https://api.bintray.com/maven/mipt-npm/$bintrayRepo/$projectName/;publish=1;override=1" + ) + credentials { + username = bintrayUser + password = bintrayApiKey + } } } - //workaround bintray bug - project.afterEvaluate { - setPublications(*project.extensions.findByType()!!.publications.names.toTypedArray()) - } - } + } +// bintray { +// user = project.findProperty("bintrayUser") as? String ?: System.getenv("BINTRAY_USER") +// key = project.findProperty("bintrayApiKey") as? String? ?: System.getenv("BINTRAY_API_KEY") +// publish = true +// override = true // for multi-platform Kotlin/Native publishing +// +// // We have to use delegateClosureOf because bintray supports only dynamic groovy syntax +// // this is a problem of this plugin +// pkg.apply { +// userOrg = "mipt-npm" +// repo = if (project.version.toString().contains("dev")) "dev" else "kscience" +// name = project.name +// issueTrackerUrl = "$vcs/issues" +// setLicenses("Apache-2.0") +// vcsUrl = vcs +// version.apply { +// name = project.version.toString() +// vcsTag = project.version.toString() +// released = Date().toString() +// } +// } +// +// //workaround bintray bug +// project.afterEvaluate { +// setPublications(*project.extensions.findByType()!!.publications.names.toTypedArray()) +// } +// +// } +//} diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt index 7823a2d..6cb2242 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt @@ -45,6 +45,23 @@ class KScienceExtension(val project: Project) { SerializationTargets(sourceSet, configuration).apply(block) } + fun useAtomic( + version: String = KScienceVersions.atomicVersion, + sourceSet: DependencySourceSet = DependencySourceSet.MAIN, + configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION + ): Unit = project.run { + plugins.apply("kotlinx-atomicfu") + useCommonDependency( + "org.jetbrains.kotlinx:atomicfu-common:$version", + dependencySourceSet = sourceSet, + dependencyConfiguration = configuration + ) + } + + fun useDokka(): Unit = project.run { + plugins.apply("org.jetbrains.dokka") + } + /** * Mark this module as an application module. JVM application should be enabled separately */ @@ -52,13 +69,16 @@ class KScienceExtension(val project: Project) { project.extensions.findByType()?.apply { explicitApi = null } + project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm"){ + project.plugins.apply("org.gradle.application") + } project.extensions.findByType()?.apply { js { binaries.executable() } } project.extensions.findByType()?.apply { - js{ + js { binaries.executable() } } @@ -67,7 +87,7 @@ class KScienceExtension(val project: Project) { /** * Activate publishing and configure it */ - fun publishing(block: Publishing.() -> Unit) = Publishing().apply(block) + fun publish(block: Publishing.() -> Unit = {}) = Publishing().apply(block) inner class Publishing { init { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt index d0940fe..bac301f 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt @@ -61,17 +61,17 @@ open class KScienceJVMPlugin : Plugin { } } - pluginManager.withPlugin("org.jetbrains.dokka") { - logger.info("Adding dokka functionality to project ${project.name}") +// pluginManager.withPlugin("org.jetbrains.dokka") { +// logger.info("Adding dokka functionality to project ${project.name}") - val dokkaHtml by tasks.getting(DokkaTask::class){ - dokkaSourceSets { - configureEach { - jdkVersion = 11 - } - } - } - } +// val dokkaHtml by tasks.getting(DokkaTask::class){ +// dokkaSourceSets { +// configureEach { +// jdkVersion.set(11) +// } +// } +// } +// } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt index 2a0b2a8..63e40c9 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt @@ -70,29 +70,29 @@ open class KScienceMPPlugin : Plugin { } } - pluginManager.withPlugin("org.jetbrains.dokka") { - logger.info("Adding dokka functionality to project ${this@run.name}") - - val dokkaHtml by tasks.getting(DokkaTask::class) { - dokkaSourceSets { - register("commonMain") { - displayName = "common" - platform = "common" - } - register("jvmMain") { - displayName = "jvm" - platform = "jvm" - } - register("jsMain") { - displayName = "js" - platform = "js" - } - configureEach { - jdkVersion = 11 - } - } - } - } +// pluginManager.withPlugin("org.jetbrains.dokka") { +// logger.info("Adding dokka functionality to project ${this@run.name}") +// +// val dokkaHtml by tasks.getting(DokkaTask::class) { +// dokkaSourceSets { +// register("commonMain") { +// displayName = "common" +// platform = "common" +// } +// register("jvmMain") { +// displayName = "jvm" +// platform = "jvm" +// } +// register("jsMain") { +// displayName = "js" +// platform = "js" +// } +// configureEach { +// jdkVersion = 11 +// } +// } +// } +// } tasks.apply { withType() { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt index d891755..40fe4df 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt @@ -13,7 +13,7 @@ object KScienceVersions { val JVM_TARGET = JavaVersion.VERSION_11 object Serialization{ - const val xmlVersion = "0.20.0.10"//to be fixed + const val xmlVersion = "0.80.0-RC"//to be fixed const val yamlVersion = "0.16.1" const val bsonVersion = "0.2.1" } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/common.kt b/src/main/kotlin/ru/mipt/npm/gradle/common.kt index c1d719f..124fcc7 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/common.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/common.kt @@ -25,7 +25,6 @@ internal fun RepositoryHandler.applyRepos(): Unit { maven("https://dl.bintray.com/kotlin/kotlin-eap") maven("https://kotlin.bintray.com/kotlinx") maven("https://kotlin.bintray.com/kotlin-js-wrappers/") - maven("https://dl.bintray.com/mipt-npm/scientifik") maven("https://dl.bintray.com/mipt-npm/kscience") maven("https://dl.bintray.com/mipt-npm/dev") maven("https://dl.bintray.com/mipt-npm/dataforge")