Change package name and fix javadoc and sources publishing

This commit is contained in:
Alexander Nozik 2021-02-21 12:11:54 +03:00
parent c37ff35b4c
commit 5d20e54ea4
6 changed files with 163 additions and 187 deletions

View File

@ -11,8 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add sonatype publishing - Add sonatype publishing
### Changed ### Changed
- Kotlin to 1.4.30 stable - Kotlin to 1.4.30 stable.
- Added intermediate jsCommon main/test sourcesSet for node plugin - Added intermediate jsCommon main/test sourcesSet for node plugin.
- Plugin names changed to `ru.mipt.npm` package.
- Common plugin id changed to `common`
- Plugins group changed to `ru.mipt.npm` with `gradle prefix
### Deprecated ### Deprecated

View File

@ -1,29 +1,29 @@
# KScience build tools # KScience build tools
A collection of gradle plugins for building and publishin *kscience* and *dataforge* projects. A collection of gradle plugins for building and publish in *kscience* and *dataforge* projects.
## ru.mipt.npm.kscience ## ru.mipt.npm.gradle.common
A primary plugin. When used with kotlin-jvm, kotlin-js or kotlin-mulitplatform configures the project for appropriate target. A primary plugin. When used with kotlin-jvm, kotlin-js or kotlin-mulitplatform configures the project for appropriate target.
## ru.mipt.npm.project ## ru.mipt.npm.gradle.project
Root project tool including JetBrains changelog plugin an kotlin binary compatibility validator tool. Root project tool including JetBrains changelog plugin an kotlin binary compatibility validator tool.
## ru.mipt.npm.publish ## ru.mipt.npm.gradle.publish
Enables publishing to maven-central, bintray, Space and github. Enables publishing to maven-central, bintray, Space and github.
## ru.mipt.npm.mpp ## ru.mipt.npm.gradle.mpp
`= kotlin("multiplatform") + ru.mipt.npm.kscience` `= kotlin("multiplatform") + ru.mipt.npm.gradle.common`
Includes JVM-IR and JS-IR-Browser targets. Includes JVM-IR and JS-IR-Browser targets.
## ru.mipt.npm.jvm ## ru.mipt.npm.gradle.jvm
`= kotlin("jvm") + ru.mipt.npm.kscience` `= kotlin("jvm") + ru.mipt.npm.gradle.common`
## ru.mipt.npm.js ## ru.mipt.npm.gradle.js
`= kotlin("js + ru.mipt.npm.kscience` `= kotlin("js + ru.mipt.npm.gradle.common`
## ru.mipt.npm.native ## ru.mipt.npm.gradle.native
add default native targets to `ru.mipt.npm.mpp` add default native targets to `ru.mipt.npm.gradle.mpp`
## ru.mipt.npm.node ## ru.mipt.npm.gradle.node
add node target to `ru.mipt.npm.mpp` add node target to `ru.mipt.npm.gradle.mpp`

View File

@ -8,7 +8,7 @@ plugins {
} }
group = "ru.mipt.npm" group = "ru.mipt.npm"
version = "0.7.8" version = "0.8.0"
description = "Build tools for DataForge and kscience projects" description = "Build tools for DataForge and kscience projects"
@ -38,156 +38,157 @@ dependencies {
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0") implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0")
} }
gradlePlugin { project.extensions.findByType<GradlePluginDevelopmentExtension>()?.apply{
plugins { plugins {
create("kscience.common") { create("common") {
id = "ru.mipt.npm.kscience" id = "ru.mipt.npm.gradle.common"
description = "The generalized kscience plugin that works in conjunction with any kotlin plugin" description = "The generalized kscience plugin that works in conjunction with any kotlin plugin"
implementationClass = "ru.mipt.npm.gradle.KScienceCommonPlugin" implementationClass = "ru.mipt.npm.gradle.KScienceCommonPlugin"
} }
create("kscience.project") { create("project") {
id = "ru.mipt.npm.project" id = "ru.mipt.npm.gradle.project"
description = "The root plugin for multimodule project infrastructure" description = "The root plugin for multimodule project infrastructure"
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin" implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
} }
create("kscience.publish") { create("publishing") {
id = "ru.mipt.npm.publish" id = "ru.mipt.npm.gradle.publish"
description = "The publication plugin for bintray and github" description = "The publication plugin for bintray and github"
implementationClass = "ru.mipt.npm.gradle.KSciencePublishPlugin" implementationClass = "ru.mipt.npm.gradle.KSciencePublishingPlugin"
} }
create("kscience.mpp") { create("mpp") {
id = "ru.mipt.npm.mpp" id = "ru.mipt.npm.gradle.mpp"
description = "Pre-configured multiplatform project" description = "Pre-configured multiplatform project"
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin" implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
} }
create("kscience.jvm") { create("jvm") {
id = "ru.mipt.npm.jvm" id = "ru.mipt.npm.gradle.jvm"
description = "Pre-configured JVM project" description = "Pre-configured JVM project"
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin" implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
} }
create("kscience.js") { create("js") {
id = "ru.mipt.npm.js" id = "ru.mipt.npm.gradle.js"
description = "Pre-configured JS project" description = "Pre-configured JS project"
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin" implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
} }
create("kscience.native") { create("native") {
id = "ru.mipt.npm.native" id = "ru.mipt.npm.gradle.native"
description = "Additional native targets to be use alongside mpp" description = "Additional native targets to be use alongside mpp"
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin" implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
} }
create("kscience.node") { create("node") {
id = "ru.mipt.npm.node" id = "ru.mipt.npm.gradle.node"
description = "Additional nodejs target to be use alongside mpp" description = "Additional nodejs target to be use alongside mpp"
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin" implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
} }
} }
} }
publishing { afterEvaluate {
val vcs = "https://github.com/mipt-npm/gradle-tools" publishing {
val vcs = "https://github.com/mipt-npm/gradle-tools"
val sourcesJar: Jar by tasks.creating(Jar::class) { val sourcesJar: Jar by tasks.creating(Jar::class) {
archiveClassifier.set("sources") archiveClassifier.set("sources")
from(sourceSets.named("main").get().allSource) from(sourceSets.named("main").get().allSource)
} }
val javadocsJar: Jar by tasks.creating(Jar::class) { val javadocsJar: Jar by tasks.creating(Jar::class) {
group = "documentation" group = "documentation"
archiveClassifier.set("javadoc") archiveClassifier.set("javadoc")
from(tasks.dokkaHtml) from(tasks.dokkaHtml)
} }
// Process each publication we have in this project // Process each publication we have in this project
publications.filterIsInstance<MavenPublication>().forEach { publication -> publications.filterIsInstance<MavenPublication>().forEach { publication ->
publication.apply {
artifact(sourcesJar)
artifact(javadocsJar)
publication.apply { pom {
artifact(sourcesJar) name.set(project.name)
artifact(javadocsJar) description.set(project.description)
pom {
name.set(project.name)
description.set(project.description)
url.set(vcs)
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("MIPT-NPM")
name.set("MIPT nuclear physics methods laboratory")
organization.set("MIPT")
organizationUrl.set("http://npm.mipt.ru")
}
}
scm {
url.set(vcs) url.set(vcs)
tag.set(project.version.toString())
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("MIPT-NPM")
name.set("MIPT nuclear physics methods laboratory")
organization.set("MIPT")
organizationUrl.set("http://npm.mipt.ru")
}
}
scm {
url.set(vcs)
tag.set(project.version.toString())
}
} }
} }
} }
val spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
val spaceUser: String? by project
val spaceToken: String? by project
if (spaceUser != null && spaceToken != null) {
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
repositories {
maven {
name = "space"
url = uri(spaceRepo)
credentials {
username = spaceUser
password = spaceToken
}
}
}
}
val sonatypeUser: String? by project
val sonatypePassword: String? by project
if (sonatypeUser != null && sonatypePassword != null) {
val sonatypeRepo: String = if (project.version.toString().contains("dev")) {
"https://oss.sonatype.org/content/repositories/snapshots"
} else {
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
}
if (plugins.findPlugin("signing") == null) {
plugins.apply("signing")
}
repositories {
maven {
name = "sonatype"
url = uri(sonatypeRepo)
credentials {
username = sonatypeUser
password = sonatypePassword
}
}
}
signing {
//useGpgCmd()
sign(publications)
}
}
} }
val spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
val spaceUser: String? by project
val spaceToken: String? by project
if (spaceUser != null && spaceToken != null) {
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
repositories {
maven {
name = "space"
url = uri(spaceRepo)
credentials {
username = spaceUser
password = spaceToken
}
}
}
}
val sonatypeUser: String? by project
val sonatypePassword: String? by project
if (sonatypeUser != null && sonatypePassword != null) {
val sonatypeRepo: String = if (project.version.toString().contains("dev")) {
"https://oss.sonatype.org/content/repositories/snapshots"
} else {
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
}
if (plugins.findPlugin("signing") == null) {
plugins.apply("signing")
}
repositories {
maven {
name = "sonatype"
url = uri(sonatypeRepo)
credentials {
username = sonatypeUser
password = sonatypePassword
}
}
}
signing {
//useGpgCmd()
sign(publications)
}
}
} }

View File

@ -128,7 +128,7 @@ class KScienceExtension(val project: Project) {
} }
fun publish() { fun publish() {
project.plugins.apply(KSciencePublishPlugin::class) project.plugins.apply(KSciencePublishingPlugin::class)
} }
} }

View File

@ -1,6 +1,5 @@
package ru.mipt.npm.gradle package ru.mipt.npm.gradle
import org.gradle.api.GradleException
import org.gradle.api.Plugin import org.gradle.api.Plugin
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.kotlin.dsl.* import org.gradle.kotlin.dsl.*
@ -19,59 +18,45 @@ class KScienceNativePlugin : Plugin<Project> {
} }
configure<KotlinMultiplatformExtension> { configure<KotlinMultiplatformExtension> {
val ideaActive = System.getProperty("idea.active") == "true" //deploy mode
linuxX64()
mingwX64()
macosX64()
if (ideaActive) { sourceSets {
//development mode val commonMain by getting
val hostOs = System.getProperty("os.name") val commonTest by getting
when { val nativeMain by creating {
hostOs == "Mac OS X" -> macosX64("native") dependsOn(commonMain)
hostOs == "Linux" -> linuxX64("native")
hostOs.startsWith("Windows") -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
} }
} else {
//deploy mode
linuxX64()
mingwX64()
macosX64()
sourceSets{ val nativeTest by creating {
val commonMain by getting dependsOn(commonTest)
val commonTest by getting }
val nativeMain by creating{ val linuxX64Main by getting {
dependsOn(commonMain) dependsOn(nativeMain)
} }
val nativeTest by creating{ val mingwX64Main by getting {
dependsOn(commonTest) dependsOn(nativeMain)
} }
val linuxX64Main by getting{ val macosX64Main by getting {
dependsOn(nativeMain) dependsOn(nativeMain)
} }
val mingwX64Main by getting{ val linuxX64Test by getting {
dependsOn(nativeMain) dependsOn(nativeTest)
} }
val macosX64Main by getting{ val mingwX64Test by getting {
dependsOn(nativeMain) dependsOn(nativeTest)
} }
val linuxX64Test by getting{ val macosX64Test by getting {
dependsOn(nativeTest) dependsOn(nativeTest)
}
val mingwX64Test by getting{
dependsOn(nativeTest)
}
val macosX64Test by getting{
dependsOn(nativeTest)
}
} }
} }
} }

View File

@ -11,16 +11,9 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
/** open class KSciencePublishingPlugin : Plugin<Project> {
* From https://github.com/Kotlin/kotlinx.serialization/blob/master/buildSrc/src/main/kotlin/Publishing.kt
*/
private fun Project.getSensitiveProperty(name: String): String? {
return project.findProperty(name) as? String ?: System.getenv(name)
}
open class KSciencePublishPlugin : Plugin<Project> { override fun apply(project: Project): Unit = project.plugins.withId("ru.mipt.npm.common") {
override fun apply(project: Project): Unit = project.plugins.withId("ru.mipt.npm.kscience") {
project.afterEvaluate { project.afterEvaluate {
if (plugins.findPlugin("maven-publish") == null) { if (plugins.findPlugin("maven-publish") == null) {
plugins.apply("maven-publish") plugins.apply("maven-publish")
@ -31,12 +24,6 @@ open class KSciencePublishPlugin : Plugin<Project> {
val vcs = findProperty("vcs") as? String val vcs = findProperty("vcs") as? String
?: githubProject?.let { "https://github.com/$githubOrg/$it" } ?: githubProject?.let { "https://github.com/$githubOrg/$it" }
// if (vcs == null) {
// project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.")
// return
// }
project.configure<PublishingExtension> { project.configure<PublishingExtension> {
plugins.withId("org.jetbrains.kotlin.js") { plugins.withId("org.jetbrains.kotlin.js") {
val kotlin = extensions.findByType<KotlinJsProjectExtension>()!! val kotlin = extensions.findByType<KotlinJsProjectExtension>()!!
@ -149,7 +136,7 @@ open class KSciencePublishPlugin : Plugin<Project> {
val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm" val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm"
val bintrayUser: String? by project val bintrayUser: String? by project
val bintrayApiKey: String? by project val bintrayApiKey: String? by project
val bintrayPublish: Boolean? by project
val bintrayRepo = if (project.version.toString().contains("dev")) { val bintrayRepo = if (project.version.toString().contains("dev")) {
"dev" "dev"
@ -159,7 +146,7 @@ open class KSciencePublishPlugin : Plugin<Project> {
val projectName = project.name val projectName = project.name
if (bintrayRepo != null && bintrayUser != null && bintrayApiKey != null) { if (bintrayPublish == true && bintrayRepo != null && bintrayUser != null && bintrayApiKey != null) {
project.logger.info("Adding bintray publishing to project [$projectName]") project.logger.info("Adding bintray publishing to project [$projectName]")
repositories { repositories {
@ -181,7 +168,7 @@ open class KSciencePublishPlugin : Plugin<Project> {
val sonatypePassword: String? by project val sonatypePassword: String? by project
val keyId: String? by project val keyId: String? by project
val signingKey: String? = getSensitiveProperty("signingKey") val signingKey: String? = project.findProperty("signingKey") as? String ?: System.getenv("signingKey")
val signingKeyPassphrase: String? by project val signingKeyPassphrase: String? by project
if (sonatypePublish == true && sonatypeUser != null && sonatypePassword != null) { if (sonatypePublish == true && sonatypeUser != null && sonatypePassword != null) {