From a5517ef03adbd8ef31eb549892bf58c7614f6a32 Mon Sep 17 00:00:00 2001 From: "anastasia.birillo" Date: Wed, 16 Aug 2023 17:07:22 +0200 Subject: [PATCH] Add publishing to space --- build.gradle.kts | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 723a963..5c6911a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,10 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import java.util.* + +val projectVersion = "1.0.0" group = "org.jetbrains.research.ml.ast.transformations" -version = "1.0-SNAPSHOT" +version = projectVersion fun properties(key: String) = project.findProperty(key).toString() @@ -11,6 +14,7 @@ plugins { id("org.jetbrains.intellij") version "1.10.0" apply true id("org.jetbrains.dokka") version "1.7.0" apply true id("org.jlleitschuh.gradle.ktlint") version "10.3.0" apply true + `maven-publish` } allprojects { @@ -57,3 +61,45 @@ allprojects { .forEach { it.enabled = false } } } + +fun getLocalProperty(key: String, file: String = "local.properties"): String? { + val properties = Properties() + + File("local.properties") + .takeIf { it.isFile } + ?.let { properties.load(it.inputStream()) } + ?: println("File $file with properties not found") + + return properties.getProperty(key, null) +} + +val spaceUsername = getLocalProperty("spaceUsername") +val spacePassword = getLocalProperty("spacePassword") + +configure(subprojects.filter { it.name != "plugin-utilities-plugin" }) { + + apply(plugin = "maven-publish") + + val subprojectName = this.name + + publishing { + publications { + register("maven") { + groupId = "org.jetbrains.research.ml.ast.transformations" + artifactId = subprojectName + version = projectVersion + from(components["java"]) + } + } + + repositories { + maven { + url = uri("https://packages.jetbrains.team/maven/p/bumblebee/bumblebee") + credentials { + username = spaceUsername + password = spacePassword + } + } + } + } +}