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
### Changed
- Kotlin to 1.4.30 stable
- Added intermediate jsCommon main/test sourcesSet for node plugin
- Kotlin to 1.4.30 stable.
- 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

View File

@ -1,29 +1,29 @@
# 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.
## ru.mipt.npm.project
## ru.mipt.npm.gradle.project
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.
## ru.mipt.npm.mpp
`= kotlin("multiplatform") + ru.mipt.npm.kscience`
## ru.mipt.npm.gradle.mpp
`= kotlin("multiplatform") + ru.mipt.npm.gradle.common`
Includes JVM-IR and JS-IR-Browser targets.
## ru.mipt.npm.jvm
`= kotlin("jvm") + ru.mipt.npm.kscience`
## ru.mipt.npm.gradle.jvm
`= kotlin("jvm") + ru.mipt.npm.gradle.common`
## ru.mipt.npm.js
`= kotlin("js + ru.mipt.npm.kscience`
## ru.mipt.npm.gradle.js
`= kotlin("js + ru.mipt.npm.gradle.common`
## ru.mipt.npm.native
add default native targets to `ru.mipt.npm.mpp`
## ru.mipt.npm.gradle.native
add default native targets to `ru.mipt.npm.gradle.mpp`
## ru.mipt.npm.node
add node target to `ru.mipt.npm.mpp`
## ru.mipt.npm.gradle.node
add node target to `ru.mipt.npm.gradle.mpp`

View File

@ -8,7 +8,7 @@ plugins {
}
group = "ru.mipt.npm"
version = "0.7.8"
version = "0.8.0"
description = "Build tools for DataForge and kscience projects"
@ -38,156 +38,157 @@ dependencies {
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0")
}
gradlePlugin {
project.extensions.findByType<GradlePluginDevelopmentExtension>()?.apply{
plugins {
create("kscience.common") {
id = "ru.mipt.npm.kscience"
create("common") {
id = "ru.mipt.npm.gradle.common"
description = "The generalized kscience plugin that works in conjunction with any kotlin plugin"
implementationClass = "ru.mipt.npm.gradle.KScienceCommonPlugin"
}
create("kscience.project") {
id = "ru.mipt.npm.project"
create("project") {
id = "ru.mipt.npm.gradle.project"
description = "The root plugin for multimodule project infrastructure"
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
}
create("kscience.publish") {
id = "ru.mipt.npm.publish"
create("publishing") {
id = "ru.mipt.npm.gradle.publish"
description = "The publication plugin for bintray and github"
implementationClass = "ru.mipt.npm.gradle.KSciencePublishPlugin"
implementationClass = "ru.mipt.npm.gradle.KSciencePublishingPlugin"
}
create("kscience.mpp") {
id = "ru.mipt.npm.mpp"
create("mpp") {
id = "ru.mipt.npm.gradle.mpp"
description = "Pre-configured multiplatform project"
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
}
create("kscience.jvm") {
id = "ru.mipt.npm.jvm"
create("jvm") {
id = "ru.mipt.npm.gradle.jvm"
description = "Pre-configured JVM project"
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
}
create("kscience.js") {
id = "ru.mipt.npm.js"
create("js") {
id = "ru.mipt.npm.gradle.js"
description = "Pre-configured JS project"
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
}
create("kscience.native") {
id = "ru.mipt.npm.native"
create("native") {
id = "ru.mipt.npm.gradle.native"
description = "Additional native targets to be use alongside mpp"
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
}
create("kscience.node") {
id = "ru.mipt.npm.node"
create("node") {
id = "ru.mipt.npm.gradle.node"
description = "Additional nodejs target to be use alongside mpp"
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
}
}
}
publishing {
val vcs = "https://github.com/mipt-npm/gradle-tools"
afterEvaluate {
publishing {
val vcs = "https://github.com/mipt-npm/gradle-tools"
val sourcesJar: Jar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.named("main").get().allSource)
}
val sourcesJar: Jar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.named("main").get().allSource)
}
val javadocsJar: Jar by tasks.creating(Jar::class) {
group = "documentation"
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}
val javadocsJar: Jar by tasks.creating(Jar::class) {
group = "documentation"
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}
// Process each publication we have in this project
publications.filterIsInstance<MavenPublication>().forEach { publication ->
// Process each publication we have in this project
publications.filterIsInstance<MavenPublication>().forEach { publication ->
publication.apply {
artifact(sourcesJar)
artifact(javadocsJar)
publication.apply {
artifact(sourcesJar)
artifact(javadocsJar)
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 {
pom {
name.set(project.name)
description.set(project.description)
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() {
project.plugins.apply(KSciencePublishPlugin::class)
project.plugins.apply(KSciencePublishingPlugin::class)
}
}

View File

@ -1,6 +1,5 @@
package ru.mipt.npm.gradle
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.*
@ -19,59 +18,45 @@ class KScienceNativePlugin : Plugin<Project> {
}
configure<KotlinMultiplatformExtension> {
val ideaActive = System.getProperty("idea.active") == "true"
//deploy mode
linuxX64()
mingwX64()
macosX64()
if (ideaActive) {
//development mode
val hostOs = System.getProperty("os.name")
sourceSets {
val commonMain by getting
val commonTest by getting
when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
hostOs.startsWith("Windows") -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
val nativeMain by creating {
dependsOn(commonMain)
}
} else {
//deploy mode
linuxX64()
mingwX64()
macosX64()
sourceSets{
val commonMain by getting
val commonTest by getting
val nativeTest by creating {
dependsOn(commonTest)
}
val nativeMain by creating{
dependsOn(commonMain)
}
val linuxX64Main by getting {
dependsOn(nativeMain)
}
val nativeTest by creating{
dependsOn(commonTest)
}
val mingwX64Main by getting {
dependsOn(nativeMain)
}
val linuxX64Main by getting{
dependsOn(nativeMain)
}
val macosX64Main by getting {
dependsOn(nativeMain)
}
val mingwX64Main by getting{
dependsOn(nativeMain)
}
val linuxX64Test by getting {
dependsOn(nativeTest)
}
val macosX64Main by getting{
dependsOn(nativeMain)
}
val mingwX64Test by getting {
dependsOn(nativeTest)
}
val linuxX64Test by getting{
dependsOn(nativeTest)
}
val mingwX64Test by getting{
dependsOn(nativeTest)
}
val macosX64Test 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
/**
* 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 KSciencePublishingPlugin : Plugin<Project> {
open class KSciencePublishPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.plugins.withId("ru.mipt.npm.kscience") {
override fun apply(project: Project): Unit = project.plugins.withId("ru.mipt.npm.common") {
project.afterEvaluate {
if (plugins.findPlugin("maven-publish") == null) {
plugins.apply("maven-publish")
@ -31,12 +24,6 @@ open class KSciencePublishPlugin : Plugin<Project> {
val vcs = findProperty("vcs") as? String
?: githubProject?.let { "https://github.com/$githubOrg/$it" }
// if (vcs == null) {
// project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.")
// return
// }
project.configure<PublishingExtension> {
plugins.withId("org.jetbrains.kotlin.js") {
val kotlin = extensions.findByType<KotlinJsProjectExtension>()!!
@ -149,7 +136,7 @@ open class KSciencePublishPlugin : Plugin<Project> {
val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm"
val bintrayUser: String? by project
val bintrayApiKey: String? by project
val bintrayPublish: Boolean? by project
val bintrayRepo = if (project.version.toString().contains("dev")) {
"dev"
@ -159,7 +146,7 @@ open class KSciencePublishPlugin : Plugin<Project> {
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]")
repositories {
@ -181,7 +168,7 @@ open class KSciencePublishPlugin : Plugin<Project> {
val sonatypePassword: 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
if (sonatypePublish == true && sonatypeUser != null && sonatypePassword != null) {