Make generateSwaggerCode method functional again

This commit is contained in:
Niko Diamadis
2024-10-17 23:47:05 -04:00
parent ac2cd916bb
commit 662ddba0bf
2 changed files with 11 additions and 14 deletions

View File

@@ -1,12 +1,7 @@
plugins { plugins {
id 'com.android.application' version '8.5.0' apply false id 'com.android.application' version '8.5.0' apply false
id 'org.jetbrains.kotlin.android' version '2.0.0' apply false id 'org.jetbrains.kotlin.android' version '2.0.0' apply false
id 'org.hidetake.swagger.generator' version '2.14.0' id 'org.hidetake.swagger.generator' version '2.19.2'
}
ext {
gotifyVersion = 'master'
specLocation = "$layout.buildDirectory/gotify.spec.json"
} }
tasks.register('clean', Delete) { tasks.register('clean', Delete) {
@@ -14,8 +9,8 @@ tasks.register('clean', Delete) {
} }
static def download(String url, String filename ) { static def download(String url, String filename ) {
new URL( url ).openConnection().with { conn -> new URI(url).toURL().openConnection().with { conn ->
new File( filename ).withOutputStream { out -> new File(filename).withOutputStream { out ->
conn.inputStream.with { inp -> conn.inputStream.with { inp ->
out << inp out << inp
inp.close() inp.close()
@@ -25,16 +20,19 @@ static def download(String url, String filename ) {
} }
tasks.register('downloadSpec') { tasks.register('downloadSpec') {
inputs.property 'version', gotifyVersion 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 { doFirst {
layout.buildDirectory.mkdirs() buildDir.asFile.mkdirs()
download("https://raw.githubusercontent.com/gotify/server/${gotifyVersion}/docs/spec.json", specLocation) download(url, specLocation)
} }
} }
swaggerSources { swaggerSources {
gotify { gotify {
inputFile = specLocation as File inputFile = "$projectDir/build/gotify.spec.json" as File
code { code {
configFile = "$projectDir/swagger.config.json" as File configFile = "$projectDir/swagger.config.json" as File
language = 'java' language = 'java'
@@ -44,7 +42,7 @@ swaggerSources {
} }
dependencies { dependencies {
swaggerCodegen 'io.swagger:swagger-codegen-cli:2.3.1' swaggerCodegen 'io.swagger.codegen.v3:swagger-codegen-cli:3.0.63'
} }
generateSwaggerCode.dependsOn downloadSpec generateSwaggerCode.dependsOn downloadSpec

View File

@@ -11,7 +11,6 @@ android.nonFinalResIds=true
android.nonTransitiveRClass=true android.nonTransitiveRClass=true
android.useAndroidX=true android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.unsafe.configuration-cache=true
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects