From 5d58767aa88184add1997bff24979d6ba84a4812 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 8 Mar 2021 22:00:06 +0300 Subject: [PATCH] Fix publication setup. Update changelog plugin --- build.gradle.kts | 6 +- .../mipt/npm/gradle/KScienceProjectPlugin.kt | 16 +++--- .../ru/mipt/npm/gradle/internal/publishing.kt | 56 ++++++++++--------- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7f561df..6ef27e9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,12 +3,12 @@ plugins { `kotlin-dsl` `maven-publish` 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" } group = "ru.mipt.npm" -version = "0.9.1" +version = "0.9.2" description = "Build tools for DataForge and kscience projects" @@ -34,7 +34,7 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion") implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.1") 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") } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt index 73f036a..5d666e4 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -17,9 +17,11 @@ import ru.mipt.npm.gradle.internal.setupPublication class KSciencePublishingExtension(val project: Project) { private var initializedFlag = false - fun setup(vcsUrl: String){ - project.setupPublication(vcsUrl) - initializedFlag = true + fun configurePublications(vcsUrl: String){ + if(!initializedFlag) { + project.setupPublication(vcsUrl) + initializedFlag = true + } } /** @@ -28,7 +30,7 @@ class KSciencePublishingExtension(val project: Project) { fun github(githubProject: String, githubOrg: String = "mipt-npm") { //automatically initialize vcs using github if(!initializedFlag){ - setup("https://github.com/$githubOrg/$githubProject") + configurePublications("https://github.com/$githubOrg/$githubProject") } project.addGithubPublishing(githubOrg, githubProject) } @@ -37,7 +39,7 @@ class KSciencePublishingExtension(val project: Project) { * Space publishing */ 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) } @@ -48,10 +50,10 @@ class KSciencePublishingExtension(val project: Project) { // var bintrayRepo: String? by project.extra /** - * Sonatype publising + * Sonatype publishing */ 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() } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/internal/publishing.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/publishing.kt index b4f9d05..dbb42a4 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/internal/publishing.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/publishing.kt @@ -59,35 +59,37 @@ internal fun Project.setupPublication(vcs: String) = allprojects { } // Process each publication we have in this project - publications.withType().forEach { publication -> - publication.artifact(dokkaJar) - publication.pom { - name.set(project.name) - description.set(project.description ?: project.name) - 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 { + afterEvaluate { + publications.withType().forEach { publication -> + publication.artifact(dokkaJar) + publication.pom { + name.set(project.name) + description.set(project.description ?: project.name) url.set(vcs) - tag.set(project.version.toString()) - //developerConnection = "scm:git:[fetch=]/*ВАША ССЫЛКА НА .git файл*/[push=]/*Повторить предыдущую ссылку*/" - } + 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()) + //developerConnection = "scm:git:[fetch=]/*ВАША ССЫЛКА НА .git файл*/[push=]/*Повторить предыдущую ссылку*/" + } + + } } } }