Skip to content

Commit

Permalink
Added basics for OSRM OpenAPI maven central publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Archdoog committed Oct 17, 2024
1 parent 5508410 commit aa8a3d2
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 25 deletions.
80 changes: 57 additions & 23 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.SonatypeHost
import org.hidetake.gradle.swagger.generator.GenerateSwaggerCode

plugins {
kotlin("jvm")
id("org.hidetake.swagger.generator") version "2.19.2"
`maven-publish`
alias(libs.plugins.swagger.codegen)
alias(libs.plugins.maven.publish)
}

repositories {
mavenCentral()
}

dependencies {
swaggerCodegen("org.openapitools:openapi-generator-cli:7.5.0")
swaggerCodegen(libs.openapi.generator)

// Dependencies of the generated code. Check out `build.gradle` in your build folder later if you're curious.
val moshiVersion = "1.15.1"
implementation("com.squareup.moshi:moshi-kotlin:$moshiVersion")
implementation("com.squareup.moshi:moshi-adapters:$moshiVersion")
implementation(libs.moshi.kotlin)
implementation(libs.moshi.adapters)

testImplementation(kotlin("test"))
}
Expand All @@ -25,6 +27,10 @@ kotlin {
jvmToolchain(17)
}

java {
withSourcesJar()
}

tasks.test {
useJUnitPlatform()
}
Expand Down Expand Up @@ -55,31 +61,59 @@ tasks.compileKotlin.configure {
dependsOn(tasks.generateSwaggerCode)
}

// This is a dependency for mavenPublishing.
tasks.named("sourcesJar") {
dependsOn(tasks.generateSwaggerCode)
}

sourceSets {
val main by getting
val osrm by swaggerSources.getting
main.kotlin.srcDir("${osrm.code.outputDir}/src/main/kotlin")
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/stadiamaps/osrm-openapi")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
val libraryVersion: String by extra

mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()

if (libraryVersion == "unspecified") {
throw GradleException("libraryVersion must be specified in settings.gradle.kts")
}

publications {
register<MavenPublication>("gpr") {
from(components["java"])
coordinates("com.stadiamaps", "osrm-openapi", libraryVersion)

groupId = "com.osrm"
artifactId = "api"
version = "0.0.9"
// TODO: Convert to Dokka?
configure(KotlinJvm(sourcesJar = true, javadocJar = JavadocJar.Javadoc()))

pom {
name.set("OSRM API Models")
description.set("Serializable objects to build OSRM's API models.")
url.set("https://github.com/stadiamaps/osrm-openapi")

licenses {
license {
name = "BSD-3-Clause"
url = "https://spdx.org/licenses/BSD-3-Clause.html"
}
}
developers {
developer {
name = "Jacob Fielding"
organization = "Rallista"
organizationUrl = "https://rallista.app/"
}
developer {
name = "Ian Wagner"
organization = "Stadia Maps"
organizationUrl = "https://stadiamaps.com/"
}
}
scm {
connection = "scm:git:https://github.com/stadiamaps/osrm-openapi.git"
developerConnection = "scm:git:ssh://github.com/stadiamaps/osrm-openapi.git"
url = "http://github.com/stadiamaps/osrm-openapi"
}
}
}
}
14 changes: 14 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[versions]
openapi = "7.5.0"
moshi = "1.15.1"
swagger-codegen = "2.19.2"
maven-publish = "0.29.0"

[libraries]
openapi-generator = { group = "org.openapitools", name = "openapi-generator-cli", version.ref = "openapi" }
moshi-kotlin = { group = "com.squareup.moshi", name = "moshi-kotlin", version.ref = "moshi" }
moshi-adapters = { group = "com.squareup.moshi", name = "moshi-adapters", version.ref = "moshi" }

[plugins]
swagger-codegen = { id = "org.hidetake.swagger.generator", version.ref = "swagger-codegen" }
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" }
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-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 5 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
plugins {
kotlin("jvm") version "1.8.22" apply false
kotlin("jvm") version "2.0.20" apply false
}

gradle.beforeProject {
extensions.extraProperties["libraryVersion"] = "0.0.10"
}

rootProject.name = "osrm-kotlin"
Expand Down

0 comments on commit aa8a3d2

Please sign in to comment.