-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from stadiamaps/feat/android-generated
Android: Generating OSRM models
- Loading branch information
Showing
12 changed files
with
560 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Gradle Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||
settings-path: ${{ github.workspace }} # location for the settings.xml file | ||
|
||
- name: Set up Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
|
||
- name: Execute Gradle build | ||
run: ./gradlew build | ||
|
||
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in | ||
# the publishing section of your build.gradle | ||
- name: Publish to GitHub Packages | ||
run: ./gradlew publish | ||
env: | ||
GITHUB_ACTOR: ${{ github.actor }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Kotlin CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "*" ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
|
||
- name: Set up Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
|
||
- name: Execute Gradle build | ||
run: ./gradlew build | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
|
||
- name: Set up Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
|
||
- name: Execute Gradle test | ||
run: ./gradlew test |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,48 @@ | ||
.build | ||
|
||
## User settings | ||
xcuserdata/ | ||
xcuserdata/ | ||
|
||
### Android ### | ||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Log/OS Files | ||
*.log | ||
|
||
# Android Studio generated files and folders | ||
captures/ | ||
.externalNativeBuild/ | ||
.cxx/ | ||
*.apk | ||
output.json | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea/ | ||
misc.xml | ||
deploymentTargetDropDown.xml | ||
render.experimental.xml | ||
|
||
# Keystore files | ||
*.jks | ||
*.keystore | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
google-services.json | ||
|
||
# Android Profiling | ||
*.hprof | ||
|
||
### Android Patch ### | ||
gen-external-apklibs | ||
|
||
# Replacement of .externalNativeBuild directories introduced | ||
# with Android Studio 3.5. | ||
|
||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import org.hidetake.gradle.swagger.generator.GenerateSwaggerCode | ||
|
||
plugins { | ||
kotlin("jvm") | ||
id("org.hidetake.swagger.generator") version "2.19.2" | ||
`maven-publish` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
swaggerCodegen("org.openapitools:openapi-generator-cli:7.5.0") | ||
|
||
// 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") | ||
|
||
testImplementation(kotlin("test")) | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(17) | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
|
||
swaggerSources { | ||
register("osrm") { | ||
val openApiFile = file("../openapi.yaml") | ||
require(openApiFile.exists()) { "OpenAPI spec file not found: $openApiFile" } | ||
|
||
setInputFile(openApiFile) | ||
code(delegateClosureOf<GenerateSwaggerCode> { | ||
language = "kotlin" | ||
components = listOf("models") | ||
additionalProperties = mapOf( | ||
"groupId" to "com.osrm", | ||
"packageName" to "com.osrm.api" | ||
) | ||
rawOptions = listOf( | ||
"--skip-validate-spec" | ||
) | ||
}) | ||
} | ||
} | ||
|
||
// Comment this out if you do NOT want the code gen to run every time you build. | ||
// There is an HTTP cache by default, so it won't necessarily make a request every single build. | ||
tasks.compileKotlin.configure { | ||
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") | ||
} | ||
} | ||
} | ||
|
||
publications { | ||
register<MavenPublication>("gpr") { | ||
from(components["java"]) | ||
|
||
groupId = "com.osrm" | ||
artifactId = "api" | ||
version = "0.0.1" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import kotlin.test.Test | ||
import com.osrm.api.models.Waypoint | ||
import kotlin.test.assertEquals | ||
|
||
class ModelTest { | ||
@Test | ||
fun testWaypoint() { | ||
val waypoint = Waypoint("name", listOf(1.0, 2.0)) | ||
assertEquals("name", waypoint.name) | ||
assertEquals(listOf(1.0, 2.0), waypoint.location) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
kotlin.code.style=official | ||
retrofitVersion=2.9.0 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.