48 lines
1.3 KiB
Groovy
48 lines
1.3 KiB
Groovy
plugins {
|
|
id 'com.android.application' version '8.5.0' apply false
|
|
id 'org.jetbrains.kotlin.android' version '2.0.0' apply false
|
|
id 'org.hidetake.swagger.generator' version '2.19.2'
|
|
}
|
|
|
|
tasks.register('clean', Delete) {
|
|
delete rootProject.layout.buildDirectory
|
|
}
|
|
|
|
static def download(String url, String filename ) {
|
|
new URI(url).toURL().openConnection().with { conn ->
|
|
new File(filename).withOutputStream { out ->
|
|
conn.inputStream.with { inp ->
|
|
out << inp
|
|
inp.close()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.register('downloadSpec') {
|
|
def gotifyVersion = 'master'
|
|
def url = "https://raw.githubusercontent.com/gotify/server/$gotifyVersion/docs/spec.json"
|
|
def buildDir = project.layout.buildDirectory.get()
|
|
def specLocation = buildDir.file('gotify.spec.json').asFile.absolutePath
|
|
doFirst {
|
|
buildDir.asFile.mkdirs()
|
|
download(url, specLocation)
|
|
}
|
|
}
|
|
|
|
swaggerSources {
|
|
gotify {
|
|
inputFile = "$projectDir/build/gotify.spec.json" as File
|
|
code {
|
|
configFile = "$projectDir/swagger.config.json" as File
|
|
language = 'java'
|
|
outputDir = "$projectDir/client" as File
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
swaggerCodegen 'io.swagger.codegen.v3:swagger-codegen-cli:3.0.63'
|
|
}
|
|
|
|
generateSwaggerCode.dependsOn downloadSpec |