Skip to content

Commit

Permalink
updated publishing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Morfly committed Jun 14, 2021
1 parent e527c06 commit 7013642
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 64 deletions.
3 changes: 2 additions & 1 deletion airin-gradle-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
`maven-publish-config`
}


dependencies {
implementation(kotlin("stdlib"))
implementation(project(":airin-gradle"))
Expand Down
3 changes: 2 additions & 1 deletion airin-gradle/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id("java-gradle-plugin")
kotlin("jvm")
id("org.jetbrains.dokka")
`maven-publish-config`
}

gradlePlugin {
Expand All @@ -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")
}
2 changes: 2 additions & 0 deletions airin-migration-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
`maven-publish-config`
}

dependencies {
Expand Down
62 changes: 1 addition & 61 deletions airin-starlark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Jar>("javadocJar") {
dependsOn(named("dokkaHtml"))
archiveClassifier.set("javadoc")
from("$buildDir/dokka/html")
}
register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(sourceSets["main"].java.srcDirs)
}
}

publishing {
publications {
register<MavenPublication>("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"])
}
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}
30 changes: 30 additions & 0 deletions buildSrc/src/main/kotlin/AirinPublications.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@file:Suppress("RemoveExplicitTypeArguments")


val airinPublications = mapOf<GradleProjectName, Publication>(

"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)
81 changes: 81 additions & 0 deletions buildSrc/src/main/kotlin/maven-publish-config.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
plugins {
`maven-publish`
signing
}

val sourceSets = the<SourceSetContainer>()

tasks {
register<Jar>("javadocJar") {
dependsOn(named("dokkaHtml"))
archiveClassifier.set("javadoc")
from("$buildDir/dokka/html")
}
register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(sourceSets["main"].allJava.srcDirs)
}
}


val airinMaven = "airinMaven"

publishing {
publications {
register<MavenPublication>(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()
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7013642

Please sign in to comment.