Skip to content

Commit

Permalink
Prepare backfila for automatically publishing to maven
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Ohlson committed Jun 6, 2023
1 parent f967529 commit 9322396
Show file tree
Hide file tree
Showing 38 changed files with 152 additions and 330 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}

steps:
- uses: actions/checkout@v2

- name: Hermit
run: ./bin/hermit env -r >> $GITHUB_ENV

- name: Assign a version
run: |
# set a version name like "2023.05.26.091805-c1fcb3a"
echo "VERSION_NAME=$(git log -n1 --pretty='format:%cd' --date=format:'%Y.%m.%d.%H%M%S')-$(git rev-parse --short=7 HEAD)" >> gradle.properties
- name: install misk-web
run: |
mkdir ~/.npm-global
Expand All @@ -27,12 +36,5 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Set gradle version
run: sed --in-place -e "s/-SNAPSHOT/-$(date +%Y%m%d.%H%M)-$(git rev-parse --short HEAD)/" gradle.properties

- name: Publish the artifacts
run: gradle publishAllPublicationsToMavenCentralRepository
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
run: gradle clean publish --stacktrace
23 changes: 14 additions & 9 deletions backfila-embedded/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
apply(plugin = "kotlin")
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.JavadocJar.Dokka
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.MavenPublishBaseExtension

plugins {
kotlin("jvm")
`java-library`
id("com.vanniktech.maven.publish.base")
}

dependencies {
implementation(Dependencies.guava)
Expand All @@ -18,12 +27,8 @@ dependencies {
testImplementation(Dependencies.kotlinTest)
}

val jar by tasks.getting(Jar::class) {
archiveBaseName.set("backfila-embedded")
configure<MavenPublishBaseExtension> {
configure(
KotlinJvm(javadocJar = Dokka("dokkaGfm"))
)
}

if (rootProject.file("hooks.gradle").exists()) {
apply(from = rootProject.file("hooks.gradle"))
}

apply(from = "$rootDir/gradle-mvn-publish.gradle")
4 changes: 0 additions & 4 deletions backfila-embedded/gradle.properties

This file was deleted.

57 changes: 43 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.allopen.gradle.AllOpenExtension
Expand All @@ -21,23 +23,22 @@ buildscript {
}
}

apply(plugin = "com.vanniktech.maven.publish.base")

allprojects {
group = project.property("GROUP") as String
version = project.findProperty("VERSION_NAME") as? String ?: "0.0-SNAPSHOT"
}

subprojects {
apply(plugin = "java")
apply(plugin = "kotlin")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "org.jetbrains.kotlin.plugin.allopen")

val compileKotlin by tasks.getting(KotlinCompile::class) {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
tasks.withType<KotlinCompile> {
dependsOn("spotlessKotlinApply")
}

val compileTestKotlin by tasks.getting(KotlinCompile::class) {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
jvmTarget = "11"
}
}

Expand Down Expand Up @@ -116,7 +117,35 @@ subprojects {
}
}

// Disable the Gradle wrapper if Gradle is managed by Hermit
tasks.named<Wrapper>("wrapper") {
enabled = false
}

allprojects {
plugins.withId("com.vanniktech.maven.publish.base") {
configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.DEFAULT, automaticRelease = true)
signAllPublications()
pom {
description.set("Backfila is a service that manages backfill state, calling into other services to do batched work.")
name.set(project.name)
url.set("https://github.com/cashapp/backfila/")
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")
}
}
scm {
url.set("https://github.com/cashapp/backfila/")
connection.set("scm:git:git://github.com/cashapp/backfila.git")
developerConnection.set("scm:git:ssh://[email protected]/cashapp/backfila.git")
}
developers {
developer {
id.set("square")
name.set("Square, Inc.")
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Dependencies {
val junitEngine = "org.junit.jupiter:junit-jupiter-engine:5.9.1"
val junitParams = "org.junit.jupiter:junit-jupiter-params:5.9.1"
val loggingApi = "io.github.microutils:kotlin-logging:2.1.23"
val mavenPublishGradlePlugin = "com.vanniktech:gradle-maven-publish-plugin:0.19.0"
val mavenPublishGradlePlugin = "com.vanniktech:gradle-maven-publish-plugin:0.25.2"
val metricsCore = "io.dropwizard.metrics:metrics-core:4.0.2"
val metricsParent = "io.dropwizard.metrics:metrics-parent:4.0.2"
val moshiCore = "com.squareup.moshi:moshi:1.13.0"
Expand Down
17 changes: 5 additions & 12 deletions client-base/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apply(plugin = "kotlin")
apply(plugin = "java")
plugins {
kotlin("jvm")
`java-library`
id("com.vanniktech.maven.publish.base")
}

dependencies {
implementation(Dependencies.apacheCommonsLang3)
Expand Down Expand Up @@ -42,13 +45,3 @@ dependencies {
// Can I make it any more obvious?
// ****************************************
}

val jar by tasks.getting(Jar::class) {
archiveBaseName.set("client-base")
}

if (rootProject.file("hooks.gradle").exists()) {
apply(from = rootProject.file("hooks.gradle"))
}

apply(from = "$rootDir/gradle-mvn-publish.gradle")
4 changes: 0 additions & 4 deletions client-base/gradle.properties

This file was deleted.

20 changes: 8 additions & 12 deletions client-dynamodb-v2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
apply(plugin = "kotlin")
plugins {
kotlin("jvm")
`java-library`
id("com.vanniktech.maven.publish.base")
}

dependencies {
implementation(Dependencies.aws2Dynamodb)
Expand Down Expand Up @@ -43,16 +47,8 @@ dependencies {
testImplementation(project(":client-misk"))
// Required until DynamoDBLocal is built with antlr >4.11 which wisp-config pulls in
testImplementation("org.antlr:antlr4-runtime:4.7.2") {
setForce(true)
version {
strictly("4.9.3")
}
}
}

val jar by tasks.getting(Jar::class) {
archiveBaseName.set("backfila-client-dynamodb-v2")
}

if (rootProject.file("hooks.gradle").exists()) {
apply(from = rootProject.file("hooks.gradle"))
}

apply(from = "$rootDir/gradle-mvn-publish.gradle")
4 changes: 0 additions & 4 deletions client-dynamodb-v2/gradle.properties

This file was deleted.

20 changes: 8 additions & 12 deletions client-dynamodb/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
apply(plugin = "kotlin")
plugins {
kotlin("jvm")
`java-library`
id("com.vanniktech.maven.publish.base")
}

dependencies {
implementation(Dependencies.awsDynamodb)
Expand Down Expand Up @@ -40,16 +44,8 @@ dependencies {
testImplementation(project(":client-misk"))
// Required until DynamoDBLocal is built with antlr >4.11 which wisp-config pulls in
testImplementation("org.antlr:antlr4-runtime:4.7.2") {
setForce(true)
version {
strictly("4.9.3")
}
}
}

val jar by tasks.getting(Jar::class) {
archiveBaseName.set("backfila-client-dynamodb")
}

if (rootProject.file("hooks.gradle").exists()) {
apply(from = rootProject.file("hooks.gradle"))
}

apply(from = "$rootDir/gradle-mvn-publish.gradle")
4 changes: 0 additions & 4 deletions client-dynamodb/gradle.properties

This file was deleted.

18 changes: 4 additions & 14 deletions client-jooq/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import nu.studer.gradle.jooq.JooqEdition
import nu.studer.gradle.jooq.JooqGenerate

Expand All @@ -13,12 +12,13 @@ buildscript {
}

plugins {
kotlin("jvm")
`java-library`
id("org.flywaydb.flyway") version Versions.flywayDBPlugin
id("nu.studer.jooq") version Versions.jooqGenPlugin
id("com.vanniktech.maven.publish.base")
}

apply(plugin = "kotlin")

dependencies {
implementation(Dependencies.guava)
implementation(Dependencies.moshiCore)
Expand Down Expand Up @@ -63,16 +63,6 @@ dependencies {

}

val jar by tasks.getting(Jar::class) {
archiveBaseName.set("backfila-client-jooq")
}

if (rootProject.file("hooks.gradle").exists()) {
apply(from = rootProject.file("hooks.gradle"))
}

apply(from = "$rootDir/gradle-mvn-publish.gradle")

flyway {
url = "jdbc:mysql://localhost:3500/backfila-jooq-codegen"
user = "root"
Expand Down Expand Up @@ -128,4 +118,4 @@ tasks {
}
}

tasks.named<nu.studer.gradle.jooq.JooqGenerate>("generateJooq") { allInputsDeclared.set(true) }
tasks.named<JooqGenerate>("generateJooq") { allInputsDeclared.set(true) }
4 changes: 0 additions & 4 deletions client-jooq/gradle.properties

This file was deleted.

16 changes: 5 additions & 11 deletions client-misk-dynamodb/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
apply(plugin = "kotlin")
plugins {
kotlin("jvm")
`java-library`
id("com.vanniktech.maven.publish.base")
}

dependencies {
implementation(Dependencies.kotlinStdLib)

api(project(":client-dynamodb"))
}

val jar by tasks.getting(Jar::class) {
archiveBaseName.set("backfila-misk-client-dynamodb")
}

if (rootProject.file("hooks.gradle").exists()) {
apply(from = rootProject.file("hooks.gradle"))
}

apply(from = "$rootDir/gradle-mvn-publish.gradle")
4 changes: 0 additions & 4 deletions client-misk-dynamodb/gradle.properties

This file was deleted.

16 changes: 5 additions & 11 deletions client-misk-hibernate/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
apply(plugin = "kotlin")
plugins {
kotlin("jvm")
`java-library`
id("com.vanniktech.maven.publish.base")
}

dependencies {
implementation(Dependencies.guava)
Expand Down Expand Up @@ -33,13 +37,3 @@ dependencies {
testImplementation(project(":backfila-embedded"))
testImplementation(project(":client-testing"))
}

val jar by tasks.getting(Jar::class) {
archiveBaseName.set("backfila-client-misk-hibernate")
}

if (rootProject.file("hooks.gradle").exists()) {
apply(from = rootProject.file("hooks.gradle"))
}

apply(from = "$rootDir/gradle-mvn-publish.gradle")
4 changes: 0 additions & 4 deletions client-misk-hibernate/gradle.properties

This file was deleted.

15 changes: 5 additions & 10 deletions client-misk-jooq/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
apply(plugin = "kotlin")
plugins {
kotlin("jvm")
`java-library`
id("com.vanniktech.maven.publish.base")
}

dependencies {
implementation(Dependencies.kotlinStdLib)

api(project(":client-jooq"))
}

val jar by tasks.getting(Jar::class) {
archiveBaseName.set("backfila-client-misk-jooq")
}
if (rootProject.file("hooks.gradle").exists()) {
apply(from = rootProject.file("hooks.gradle"))
}

apply(from = "$rootDir/gradle-mvn-publish.gradle")
4 changes: 0 additions & 4 deletions client-misk-jooq/gradle.properties

This file was deleted.

Loading

0 comments on commit 9322396

Please sign in to comment.