adjust release publishing

This commit is contained in:
Alexander Nozik 2021-05-18 12:16:33 +03:00
parent 5ff90436f5
commit 023ca7b80c
9 changed files with 31 additions and 22 deletions

View File

@ -8,7 +8,7 @@ plugins {
} }
group = "ru.mipt.npm" group = "ru.mipt.npm"
version = "0.9.7" version = "0.9.8"
description = "Build tools for DataForge and kscience projects" description = "Build tools for DataForge and kscience projects"

View File

@ -1,2 +0,0 @@
rootProject.name = 'gradle-tools'

1
settings.gradle.kts Normal file
View File

@ -0,0 +1 @@
rootProject.name = "gradle-tools"

View File

@ -40,7 +40,6 @@ open class KScienceCommonPlugin : Plugin<Project> {
} }
tasks.withType<KotlinJvmCompile> { tasks.withType<KotlinJvmCompile> {
kotlinOptions { kotlinOptions {
useIR = true
jvmTarget = KScienceVersions.JVM_TARGET.toString() jvmTarget = KScienceVersions.JVM_TARGET.toString()
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
} }
@ -95,7 +94,6 @@ open class KScienceCommonPlugin : Plugin<Project> {
jvm { jvm {
compilations.all { compilations.all {
kotlinOptions { kotlinOptions {
useIR = true
jvmTarget = KScienceVersions.JVM_TARGET.toString() jvmTarget = KScienceVersions.JVM_TARGET.toString()
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
} }

View File

@ -147,6 +147,7 @@ class KScienceExtension(val project: Project) {
} }
} }
@Deprecated("Replace by applying maven-publish plugin")
fun publish() { fun publish() {
project.plugins.apply(MavenPublishPlugin::class) project.plugins.apply(MavenPublishPlugin::class)
} }

View File

@ -16,7 +16,7 @@ import ru.mipt.npm.gradle.internal.*
class KSciencePublishingExtension(val project: Project) { class KSciencePublishingExtension(val project: Project) {
private var initializedFlag = false private var initializedFlag = false
fun configurePublications(vcsUrl: String) { fun vcs(vcsUrl: String) {
if (!initializedFlag) { if (!initializedFlag) {
project.setupPublication(vcsUrl) project.setupPublication(vcsUrl)
initializedFlag = true initializedFlag = true
@ -25,21 +25,35 @@ class KSciencePublishingExtension(val project: Project) {
/** /**
* github publishing * github publishing
* @param publish include github packages in release publishing. By default - false
*/ */
fun github(githubProject: String, githubOrg: String = "mipt-npm") { fun github(githubProject: String, githubOrg: String = "mipt-npm", publish: Boolean = false) {
//automatically initialize vcs using github //automatically initialize vcs using github
if (!initializedFlag) { if (!initializedFlag) {
configurePublications("https://github.com/$githubOrg/$githubProject") vcs("https://github.com/$githubOrg/$githubProject")
} }
project.addGithubPublishing(githubOrg, githubProject) project.addGithubPublishing(githubOrg, githubProject)
if (publish) {
val publicationTask = project.tasks.getByName("publish${project.publicationTarget}ToGithubRepository")
releaseTask?.dependsOn(publicationTask)
}
}
private val releaseTask by lazy {
project.tasks.findByName("release")
} }
/** /**
* 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", publish: Boolean = false) {
require(initializedFlag) { "The publishing is not set up use 'configurePublications' method to do so" } require(initializedFlag) { "The project vcs is not set up use 'vcs' method to do so" }
project.addSpacePublishing(spaceRepo) project.addSpacePublishing(spaceRepo)
if (publish) {
val publicationTask = project.tasks.getByName("publish${project.publicationTarget}ToSpaceRepository")
releaseTask?.dependsOn(publicationTask)
}
} }
// // Bintray publishing // // Bintray publishing
@ -51,9 +65,13 @@ class KSciencePublishingExtension(val project: Project) {
/** /**
* Sonatype publishing * Sonatype publishing
*/ */
fun sonatype() { fun sonatype(publish: Boolean = true) {
require(initializedFlag) { "The publishing is not set up use 'configurePublications' method to do so" } require(initializedFlag) { "The project vcs is not set up use 'vcs' method to do so" }
project.addSonatypePublishing() project.addSonatypePublishing()
if (publish) {
val publicationTask = project.tasks.getByName("publish${project.publicationTarget}ToSonatypeRepository")
releaseTask?.dependsOn(publicationTask)
}
} }
} }
@ -65,7 +83,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
override fun apply(target: Project): Unit = target.run { override fun apply(target: Project): Unit = target.run {
apply<ChangelogPlugin>() apply<ChangelogPlugin>()
if(!isSnapshot()) { if (!isSnapshot()) {
configure<ChangelogPluginExtension> { configure<ChangelogPluginExtension> {
version = project.version.toString() version = project.version.toString()
} }

View File

@ -11,7 +11,7 @@ object KScienceVersions {
const val coroutinesVersion = "1.5.0" const val coroutinesVersion = "1.5.0"
const val serializationVersion = "1.2.1" const val serializationVersion = "1.2.1"
const val atomicVersion = "0.16.1" const val atomicVersion = "0.16.1"
const val ktorVersion = "1.5.3" const val ktorVersion = "1.5.4"
const val htmlVersion = "0.7.3" const val htmlVersion = "0.7.3"
const val dateTimeVersion = "0.2.0" const val dateTimeVersion = "0.2.0"

View File

@ -22,7 +22,6 @@ internal fun LanguageSettingsBuilder.applySettings(): Unit {
internal fun RepositoryHandler.applyRepos(): Unit { internal fun RepositoryHandler.applyRepos(): Unit {
mavenCentral() mavenCentral()
maven("https://repo.kotlin.link") maven("https://repo.kotlin.link")
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers") maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers")
} }

View File

@ -110,7 +110,7 @@ internal val Project.publicationTarget: String
internal fun Project.addGithubPublishing( internal fun Project.addGithubPublishing(
githubOrg: String, githubOrg: String,
githubProject: String githubProject: String,
) { ) {
if (requestPropertyOrNull("publishing.enabled") != "true") { if (requestPropertyOrNull("publishing.enabled") != "true") {
logger.info("Skipping github publishing because publishing is disabled") logger.info("Skipping github publishing because publishing is disabled")
@ -139,8 +139,6 @@ internal fun Project.addGithubPublishing(
} }
} }
} }
val publicationTask = tasks.getByName("publish${publicationTarget}ToGithubRepository")
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
} }
} }
} }
@ -174,8 +172,6 @@ internal fun Project.addSpacePublishing(spaceRepo: String) {
} }
} }
} }
val publicationTask = tasks.getByName("publish${publicationTarget}ToSpaceRepository")
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
} }
} }
} }
@ -229,8 +225,6 @@ internal fun Project.addSonatypePublishing() {
} }
} }
} }
val publicationTask = tasks.getByName("publish${publicationTarget}ToSonatypeRepository")
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
} }
} }
} }