diff --git a/airin-gradle-android/build.gradle.kts b/airin-gradle-android/build.gradle.kts index 76e920b7..b46fbb87 100644 --- a/airin-gradle-android/build.gradle.kts +++ b/airin-gradle-android/build.gradle.kts @@ -1,8 +1,9 @@ plugins { kotlin("jvm") + id("org.jetbrains.dokka") + `maven-publish-config` } - dependencies { implementation(kotlin("stdlib")) implementation(project(":airin-gradle")) diff --git a/airin-gradle/build.gradle.kts b/airin-gradle/build.gradle.kts index c75dcdb4..66cd85da 100644 --- a/airin-gradle/build.gradle.kts +++ b/airin-gradle/build.gradle.kts @@ -1,6 +1,8 @@ plugins { id("java-gradle-plugin") kotlin("jvm") + id("org.jetbrains.dokka") + `maven-publish-config` } gradlePlugin { @@ -16,5 +18,4 @@ dependencies { implementation(kotlin("stdlib")) api(project(":airin-starlark")) api(project(":airin-migration-core")) -// implementation("com.android.tools.build:gradle:4.1.0") } \ No newline at end of file diff --git a/airin-migration-core/build.gradle.kts b/airin-migration-core/build.gradle.kts index 2066b082..c05511c2 100644 --- a/airin-migration-core/build.gradle.kts +++ b/airin-migration-core/build.gradle.kts @@ -1,5 +1,7 @@ plugins { kotlin("jvm") + id("org.jetbrains.dokka") + `maven-publish-config` } dependencies { diff --git a/airin-starlark/build.gradle.kts b/airin-starlark/build.gradle.kts index 47c901dc..0d918b78 100644 --- a/airin-starlark/build.gradle.kts +++ b/airin-starlark/build.gradle.kts @@ -5,8 +5,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet plugins { kotlin("jvm") id("org.jetbrains.dokka") - `maven-publish` - signing + `maven-publish-config` } sourceSets { @@ -35,63 +34,4 @@ dependencies { val kotestVersion: String by rootProject.extra testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion") testImplementation("io.kotest:kotest-assertions-core:$kotestVersion") -} - -tasks { - register("javadocJar") { - dependsOn(named("dokkaHtml")) - archiveClassifier.set("javadoc") - from("$buildDir/dokka/html") - } - register("sourcesJar") { - archiveClassifier.set("sources") - from(sourceSets["main"].java.srcDirs) - } -} - -publishing { - publications { - register("mavenAirinStarlark") { - artifactId = "airin-starlark" - artifact(tasks.getByName("javadocJar")) - artifact(tasks.getByName("sourcesJar")) - - pom { - name.set("Airin Starlark") - description.set("A Kotlin tool for migrating Gradle projects to Bazel. It provides a declarative and type-safe Starlark template engine for generating Bazel build scripts.") - url.set("https://github.com/Morfly/airin") - - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - developers { - developer { - id.set("morfly") - name.set("Pavlo Stavytskyi") - email.set("pavlo.stavytskyi@gmail.com") - } - } - scm { - connection.set("scm:git:git://github.com/Morfly/airin.git") - developerConnection.set("scm:git:ssh://github.com/Morfly/airin.git") - url.set("https://github.com/Morfly/airin") - } - } - - from(components["kotlin"]) - } - - repositories { - maven { - url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") - } - } - } -} - -signing { - sign(publishing.publications["mavenAirinStarlark"]) } \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..b22ed732 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/AirinPublications.kt b/buildSrc/src/main/kotlin/AirinPublications.kt new file mode 100644 index 00000000..b5dcbab1 --- /dev/null +++ b/buildSrc/src/main/kotlin/AirinPublications.kt @@ -0,0 +1,30 @@ +@file:Suppress("RemoveExplicitTypeArguments") + + +val airinPublications = mapOf( + + "airin-starlark" to Publication( + name = "Airin Starlark", + description = "A declarative, type-safe Starlark template engine that allows writing Starlark code templates in Kotlin." + ), + + "airin-migration-core" to Publication( + name = "Airin Migration Core", + description = "Core APIs for migration to Bazel." + ), + + "airin-gradle" to Publication( + name = "Airin Gradle", + description = "Airin Gradle plugin for migration to Bazel." + ), + + "airin-gradle-android" to Publication( + name = "Airin Gradle Android", + description = "Android extensions for Airin Gradle plugin." + ) +) + + +typealias GradleProjectName = String + +data class Publication(val name: String, val description: String) \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/maven-publish-config.gradle.kts b/buildSrc/src/main/kotlin/maven-publish-config.gradle.kts new file mode 100644 index 00000000..da144a06 --- /dev/null +++ b/buildSrc/src/main/kotlin/maven-publish-config.gradle.kts @@ -0,0 +1,81 @@ +plugins { + `maven-publish` + signing +} + +val sourceSets = the() + +tasks { + register("javadocJar") { + dependsOn(named("dokkaHtml")) + archiveClassifier.set("javadoc") + from("$buildDir/dokka/html") + } + register("sourcesJar") { + archiveClassifier.set("sources") + from(sourceSets["main"].allJava.srcDirs) + } +} + + +val airinMaven = "airinMaven" + +publishing { + publications { + register(airinMaven) { + artifactId = project.name + artifact(tasks.getByName("javadocJar")) + artifact(tasks.getByName("sourcesJar")) + + pom { + name.set(airinPublications[project.name]!!.name) + description.set(airinPublications[project.name]!!.description) + url.set("https://github.com/Morfly/airin") + + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("morfly") + name.set("Pavlo Stavytskyi") + email.set("pavlo.stavytskyi@gmail.com") + } + } + scm { + connection.set("scm:git:git://github.com/Morfly/airin.git") + developerConnection.set("scm:git:ssh://github.com/Morfly/airin.git") + url.set("https://github.com/Morfly/airin") + } + } + + from(components["kotlin"]) + } + + repositories { + maven { + // publishAirinMavenPublicationToMavenRepository + url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + val sonatypeUsername: String by project + val sonatypePassword: String by project + username = sonatypeUsername + password = sonatypePassword + } + } + maven { + // publishAirinMavenPublicationToLocalRepository + name = "local" + url = uri("$buildDir/repo") + } + } + } +} + +signing { + sign(publishing.publications[airinMaven]) +// useGpgCmd() +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index da9702f9..0f80bbf5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists