Fix publication setup. Update changelog plugin

This commit is contained in:
Alexander Nozik 2021-03-08 22:00:06 +03:00
parent 757b609d26
commit 5d58767aa8
3 changed files with 41 additions and 37 deletions

View File

@ -3,12 +3,12 @@ plugins {
`kotlin-dsl` `kotlin-dsl`
`maven-publish` `maven-publish`
signing signing
id("org.jetbrains.changelog") version "1.0.0" id("org.jetbrains.changelog") version "1.1.2"
id("org.jetbrains.dokka") version "1.4.20" id("org.jetbrains.dokka") version "1.4.20"
} }
group = "ru.mipt.npm" group = "ru.mipt.npm"
version = "0.9.1" version = "0.9.2"
description = "Build tools for DataForge and kscience projects" description = "Build tools for DataForge and kscience projects"
@ -34,7 +34,7 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.1") implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.1")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20") implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20")
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.0.0") implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.1.2")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0") implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0")
} }

View File

@ -17,10 +17,12 @@ import ru.mipt.npm.gradle.internal.setupPublication
class KSciencePublishingExtension(val project: Project) { class KSciencePublishingExtension(val project: Project) {
private var initializedFlag = false private var initializedFlag = false
fun setup(vcsUrl: String){ fun configurePublications(vcsUrl: String){
if(!initializedFlag) {
project.setupPublication(vcsUrl) project.setupPublication(vcsUrl)
initializedFlag = true initializedFlag = true
} }
}
/** /**
* github publishing * github publishing
@ -28,7 +30,7 @@ class KSciencePublishingExtension(val project: Project) {
fun github(githubProject: String, githubOrg: String = "mipt-npm") { fun github(githubProject: String, githubOrg: String = "mipt-npm") {
//automatically initialize vcs using github //automatically initialize vcs using github
if(!initializedFlag){ if(!initializedFlag){
setup("https://github.com/$githubOrg/$githubProject") configurePublications("https://github.com/$githubOrg/$githubProject")
} }
project.addGithubPublishing(githubOrg, githubProject) project.addGithubPublishing(githubOrg, githubProject)
} }
@ -37,7 +39,7 @@ class KSciencePublishingExtension(val project: Project) {
* Space publishing * Space publishing
*/ */
fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven") { fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven") {
require(initializedFlag){"The publishing is not set up use 'setup' method to do so"} require(initializedFlag){"The publishing is not set up use 'configurePublications' method to do so"}
project.addSpacePublishing(spaceRepo) project.addSpacePublishing(spaceRepo)
} }
@ -48,10 +50,10 @@ class KSciencePublishingExtension(val project: Project) {
// var bintrayRepo: String? by project.extra // var bintrayRepo: String? by project.extra
/** /**
* Sonatype publising * Sonatype publishing
*/ */
fun sonatype(){ fun sonatype(){
require(initializedFlag){"The publishing is not set up use 'setup' method to do so"} require(initializedFlag){"The publishing is not set up use 'configurePublications' method to do so"}
project.addSonatypePublishing() project.addSonatypePublishing()
} }
} }

View File

@ -59,6 +59,7 @@ internal fun Project.setupPublication(vcs: String) = allprojects {
} }
// Process each publication we have in this project // Process each publication we have in this project
afterEvaluate {
publications.withType<MavenPublication>().forEach { publication -> publications.withType<MavenPublication>().forEach { publication ->
publication.artifact(dokkaJar) publication.artifact(dokkaJar)
publication.pom { publication.pom {
@ -92,6 +93,7 @@ internal fun Project.setupPublication(vcs: String) = allprojects {
} }
} }
} }
}
} }
internal fun Project.isSnapshot() = version.toString().contains("dev") || version.toString().endsWith("SNAPSHOT") internal fun Project.isSnapshot() = version.toString().contains("dev") || version.toString().endsWith("SNAPSHOT")