diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java index c33745d7e8a..b94c939f8e1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java @@ -459,8 +459,6 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi if (additionalProperties.containsKey(USE_ANDROID_MAVEN_GRADLE_PLUGIN)) { this.setUseAndroidMavenGradlePlugin(Boolean.valueOf((String) additionalProperties .get(USE_ANDROID_MAVEN_GRADLE_PLUGIN))); - } else { - additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin); } if (additionalProperties.containsKey(ANDROID_GRADLE_VERSION)) { @@ -483,8 +481,9 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi this.setSerializableModel(Boolean.valueOf(additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL).toString())); } - // need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string + // need to put back boolean properties into additionalProperties as the values in additionalProperties are strings additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); + additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin); //make api and model doc path available in mustache template additionalProperties.put("apiDocPath", apiDocPath); @@ -524,7 +523,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); - // supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle")); + supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle")); supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle")); supportingFiles.add(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml")); supportingFiles.add(new SupportingFile("apiInvoker.mustache", diff --git a/modules/openapi-generator/src/main/resources/android/build.mustache b/modules/openapi-generator/src/main/resources/android/build.mustache index 729df266d1e..4034e0a79f6 100644 --- a/modules/openapi-generator/src/main/resources/android/build.mustache +++ b/modules/openapi-generator/src/main/resources/android/build.mustache @@ -1,50 +1,26 @@ -{{#useAndroidMavenGradlePlugin}} -group = '{{groupId}}' -project.version = '{{artifactVersion}}' -{{/useAndroidMavenGradlePlugin}} - -buildscript { - repositories { - maven { url "https://repo1.maven.org/maven2" } - jcenter() - } - dependencies { - {{#androidGradleVersion}} - classpath 'com.android.tools.build:gradle:{{{.}}}' - {{/androidGradleVersion}} - {{^androidGradleVersion}} - classpath 'com.android.tools.build:gradle:2.3.+' - {{/androidGradleVersion}} - {{#useAndroidMavenGradlePlugin}} - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' - {{/useAndroidMavenGradlePlugin}} - } +plugins { + {{#androidGradleVersion}} + id 'com.android.library' version '{{{.}}}' + {{/androidGradleVersion}} + {{^androidGradleVersion}} + id 'com.android.library' version '8.0.0' + {{/androidGradleVersion}} + id 'maven-publish' } -allprojects { - repositories { - jcenter() - } -} - - -apply plugin: 'com.android.library' -{{#useAndroidMavenGradlePlugin}} -apply plugin: 'com.github.dcendents.android-maven' -{{/useAndroidMavenGradlePlugin}} - android { + namespace "{{invokerPackage}}" {{#androidSdkVersion}} compileSdkVersion {{{.}}} {{/androidSdkVersion}} {{^androidSdkVersion}} - compileSdkVersion 25 + compileSdkVersion 33 {{/androidSdkVersion}} {{#androidBuildToolsVersion}} buildToolsVersion '{{{.}}}' {{/androidBuildToolsVersion}} {{^androidBuildToolsVersion}} - buildToolsVersion '25.0.2' + buildToolsVersion '34.0.0' {{/androidBuildToolsVersion}} useLibrary 'org.apache.http.legacy' defaultConfig { @@ -53,27 +29,20 @@ android { targetSdkVersion {{{.}}} {{/androidSdkVersion}} {{^androidSdkVersion}} - targetSdkVersion 25 + targetSdkVersion 33 {{/androidSdkVersion}} } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - - // Rename the aar correctly - libraryVariants.all { variant -> - variant.outputs.each { output -> - def outputFile = output.outputFile - if (outputFile != null && outputFile.name.endsWith('.aar')) { - def fileName = "${project.name}-${variant.baseName}-${version}.aar" - output.outputFile = new File(outputFile.parent, fileName) - } + publishing { + singleVariant('release') { + withSourcesJar() } } } - ext { swagger_annotations_version = "1.6.6" gson_version = "2.10.1" @@ -83,38 +52,29 @@ ext { } dependencies { - compile "io.swagger:swagger-annotations:$swagger_annotations_version" - compile "com.google.code.gson:gson:$gson_version" - compile "org.apache.httpcomponents:httpcore:$httpcore_version" - compile "org.apache.httpcomponents:httpclient:$httpclient_version" - compile ("org.apache.httpcomponents:httpcore:$httpcore_version") { + implementation "io.swagger:swagger-annotations:$swagger_annotations_version" + implementation "com.google.code.gson:gson:$gson_version" + implementation "org.apache.httpcomponents:httpcore:$httpcore_version" + implementation "org.apache.httpcomponents:httpclient:$httpclient_version" + implementation ("org.apache.httpcomponents:httpcore:$httpcore_version") { exclude(group: 'org.apache.httpcomponents', module: 'httpclient') } - compile ("org.apache.httpcomponents:httpmime:$httpclient_version") { + implementation ("org.apache.httpcomponents:httpmime:$httpclient_version") { exclude(group: 'org.apache.httpcomponents', module: 'httpclient') } - testCompile "junit:junit:$junit_version" + testImplementation "junit:junit:$junit_version" } -afterEvaluate { - android.libraryVariants.all { variant -> - def task = project.tasks.create "jar${variant.name.capitalize()}", Jar - task.description = "Create jar artifact for ${variant.name}" - task.dependsOn variant.javaCompile - task.from variant.javaCompile.destinationDirectory - task.destinationDirectory = project.file("${project.buildDir}/outputs/jar") - task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" - artifacts.add('archives', task); +publishing { + publications { + release(MavenPublication) { + groupId = '{{groupId}}' + artifactId = '{{artifactId}}' + version = '{{artifactVersion}}' + + afterEvaluate { + from components.release + } + } } } - -{{#useAndroidMavenGradlePlugin}} -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -artifacts { - archives sourcesJar -} -{{/useAndroidMavenGradlePlugin}} diff --git a/modules/openapi-generator/src/main/resources/android/gradle-wrapper.properties.mustache b/modules/openapi-generator/src/main/resources/android/gradle-wrapper.properties.mustache index 4d9ca164914..d951fac2bf3 100644 --- a/modules/openapi-generator/src/main/resources/android/gradle-wrapper.properties.mustache +++ b/modules/openapi-generator/src/main/resources/android/gradle-wrapper.properties.mustache @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/modules/openapi-generator/src/main/resources/android/libraries/volley/build.mustache b/modules/openapi-generator/src/main/resources/android/libraries/volley/build.mustache index b21fdcb60c3..ef4f74e79c4 100644 --- a/modules/openapi-generator/src/main/resources/android/libraries/volley/build.mustache +++ b/modules/openapi-generator/src/main/resources/android/libraries/volley/build.mustache @@ -1,44 +1,35 @@ -{{#useAndroidMavenGradlePlugin}} -group = '{{groupId}}' -project.version = '{{artifactVersion}}' -{{/useAndroidMavenGradlePlugin}} - -buildscript { - repositories { - mavenLocal() - google() - maven { - url 'https://dl.google.com/dl/android/maven2' - } - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.2.+' - {{#useAndroidMavenGradlePlugin}} - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' - {{/useAndroidMavenGradlePlugin}} - } +plugins { + {{#androidGradleVersion}} + id 'com.android.library' version '{{{.}}}' + {{/androidGradleVersion}} + {{^androidGradleVersion}} + id 'com.android.library' version '8.0.0' + {{/androidGradleVersion}} + id 'maven-publish' } -allprojects { - repositories { - google() - jcenter() - } -} - - -apply plugin: 'com.android.library' -{{#useAndroidMavenGradlePlugin}} -apply plugin: 'com.github.dcendents.android-maven' -{{/useAndroidMavenGradlePlugin}} - android { - compileSdkVersion 26 - buildToolsVersion '28.0.3' + namespace "{{invokerPackage}}" + {{#androidSdkVersion}} + compileSdkVersion {{{.}}} + {{/androidSdkVersion}} + {{^androidSdkVersion}} + compileSdkVersion 33 + {{/androidSdkVersion}} + {{#androidBuildToolsVersion}} + buildToolsVersion '{{{.}}}' + {{/androidBuildToolsVersion}} + {{^androidBuildToolsVersion}} + buildToolsVersion '34.0.0' + {{/androidBuildToolsVersion}} defaultConfig { minSdkVersion 14 - targetSdkVersion 26 + {{#androidSdkVersion}} + targetSdkVersion {{{.}}} + {{/androidSdkVersion}} + {{^androidSdkVersion}} + targetSdkVersion 33 + {{/androidSdkVersion}} } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -47,24 +38,23 @@ android { lintOptions { abortOnError false } - - // Rename the aar correctly - libraryVariants.all { variant -> - variant.outputs.all { output -> - if (outputFile != null && outputFileName.endsWith('.aar')) { - outputFileName = "${archivesBaseName}-${version}.aar" - } - } + packagingOptions { + resources.excludes += "META-INF/DEPENDENCIES" } - testOptions { unitTests.returnDefaultValues = true } + publishing { + singleVariant('release') { + withSourcesJar() + } + } } ext { swagger_annotations_version = "1.6.6" gson_version = "2.10.1" + httpcore_version = "4.4.16" httpmime_version = "4.5.14" volley_version = "1.2.1" junit_version = "4.13.2" @@ -75,32 +65,28 @@ ext { dependencies { implementation "io.swagger:swagger-annotations:$swagger_annotations_version" implementation "com.google.code.gson:gson:$gson_version" - implementation "org.apache.httpcomponents:httpmime:$httpmime_version" + implementation ("org.apache.httpcomponents:httpcore:$httpcore_version") { + exclude(group: "org.apache.httpcomponents", module: "httpclient") + } + implementation ("org.apache.httpcomponents:httpmime:$httpmime_version") { + exclude(group: "org.apache.httpcomponents", module: "httpclient") + } implementation "com.android.volley:volley:${volley_version}" testImplementation "junit:junit:$junit_version" testImplementation "org.robolectric:robolectric:${robolectric_version}" testImplementation "net.jodah:concurrentunit:${concurrent_unit_version}" } -afterEvaluate { - android.libraryVariants.all { variant -> - def task = project.tasks.create "jar${variant.name.capitalize()}", Jar - task.description = "Create jar artifact for ${variant.name}" - task.dependsOn variant.javaCompile - task.from variant.javaCompile.destinationDirectory - task.destinationDirectory = project.file("${project.buildDir}/outputs/jar") - task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" - artifacts.add('archives', task); +publishing { + publications { + release(MavenPublication) { + groupId = '{{groupId}}' + artifactId = '{{artifactId}}' + version = '{{artifactVersion}}' + + afterEvaluate { + from components.release + } + } } } - -{{#useAndroidMavenGradlePlugin}} -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -artifacts { - archives sourcesJar -} -{{/useAndroidMavenGradlePlugin}} diff --git a/modules/openapi-generator/src/main/resources/android/settings.gradle.mustache b/modules/openapi-generator/src/main/resources/android/settings.gradle.mustache index ba0114cb176..457e1537fda 100644 --- a/modules/openapi-generator/src/main/resources/android/settings.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/android/settings.gradle.mustache @@ -1 +1,17 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + rootProject.name = "{{artifactId}}" diff --git a/samples/client/petstore/android/httpclient/.openapi-generator/VERSION b/samples/client/petstore/android/httpclient/.openapi-generator/VERSION index 5f68295fc19..7e7b8b9bc73 100644 --- a/samples/client/petstore/android/httpclient/.openapi-generator/VERSION +++ b/samples/client/petstore/android/httpclient/.openapi-generator/VERSION @@ -1 +1 @@ -6.0.0-SNAPSHOT \ No newline at end of file +7.7.0-SNAPSHOT diff --git a/samples/client/petstore/android/httpclient/README.md b/samples/client/petstore/android/httpclient/README.md index 325ce22b90c..da0f496c192 100644 --- a/samples/client/petstore/android/httpclient/README.md +++ b/samples/client/petstore/android/httpclient/README.md @@ -117,13 +117,6 @@ Class | Method | HTTP request | Description ## Documentation for Authorization Authentication schemes defined for the API: -### api_key - -- **Type**: API key - -- **API key parameter name**: api_key -- **Location**: HTTP header - ### petstore_auth @@ -134,6 +127,13 @@ Authentication schemes defined for the API: - write:pets: modify pets in your account - read:pets: read your pets +### api_key + +- **Type**: API key + +- **API key parameter name**: api_key +- **Location**: HTTP header + ## Recommendation diff --git a/samples/client/petstore/android/httpclient/build.gradle b/samples/client/petstore/android/httpclient/build.gradle index d0dbd5aaf7a..99a604edddd 100644 --- a/samples/client/petstore/android/httpclient/build.gradle +++ b/samples/client/petstore/android/httpclient/build.gradle @@ -1,92 +1,60 @@ -group = 'org.openapitools' -project.version = '1.0.0' - -buildscript { - repositories { - maven { url "https://repo1.maven.org/maven2" } - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:2.3.+' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' - } +plugins { + id 'com.android.library' version '8.0.0' + id 'maven-publish' } -allprojects { - repositories { - jcenter() - } -} - - -apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' - android { - compileSdkVersion 25 - buildToolsVersion '25.0.2' + namespace "org.openapitools.client" + compileSdkVersion 33 + buildToolsVersion '34.0.0' useLibrary 'org.apache.http.legacy' defaultConfig { minSdkVersion 14 - targetSdkVersion 25 + targetSdkVersion 33 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - - // Rename the aar correctly - libraryVariants.all { variant -> - variant.outputs.each { output -> - def outputFile = output.outputFile - if (outputFile != null && outputFile.name.endsWith('.aar')) { - def fileName = "${project.name}-${variant.baseName}-${version}.aar" - output.outputFile = new File(outputFile.parent, fileName) - } + publishing { + singleVariant('release') { + withSourcesJar() } } } - ext { swagger_annotations_version = "1.6.6" - gson_version = "2.8.9" + gson_version = "2.10.1" httpclient_version = "4.5.13" httpcore_version = "4.4.4" junit_version = "4.13" } dependencies { - compile "io.swagger:swagger-annotations:$swagger_annotations_version" - compile "com.google.code.gson:gson:$gson_version" - compile "org.apache.httpcomponents:httpcore:$httpcore_version" - compile "org.apache.httpcomponents:httpclient:$httpclient_version" - compile ("org.apache.httpcomponents:httpcore:$httpcore_version") { + implementation "io.swagger:swagger-annotations:$swagger_annotations_version" + implementation "com.google.code.gson:gson:$gson_version" + implementation "org.apache.httpcomponents:httpcore:$httpcore_version" + implementation "org.apache.httpcomponents:httpclient:$httpclient_version" + implementation ("org.apache.httpcomponents:httpcore:$httpcore_version") { exclude(group: 'org.apache.httpcomponents', module: 'httpclient') } - compile ("org.apache.httpcomponents:httpmime:$httpclient_version") { + implementation ("org.apache.httpcomponents:httpmime:$httpclient_version") { exclude(group: 'org.apache.httpcomponents', module: 'httpclient') } - testCompile "junit:junit:$junit_version" + testImplementation "junit:junit:$junit_version" } -afterEvaluate { - android.libraryVariants.all { variant -> - def task = project.tasks.create "jar${variant.name.capitalize()}", Jar - task.description = "Create jar artifact for ${variant.name}" - task.dependsOn variant.javaCompile - task.from variant.javaCompile.destinationDir - task.destinationDir = project.file("${project.buildDir}/outputs/jar") - task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" - artifacts.add('archives', task); +publishing { + publications { + release(MavenPublication) { + groupId = 'org.openapitools' + artifactId = 'openapi-android-client' + version = '1.0.0' + + afterEvaluate { + from components.release + } + } } } - -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -artifacts { - archives sourcesJar -} diff --git a/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.properties index 4d9ca164914..d951fac2bf3 100644 --- a/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.properties +++ b/samples/client/petstore/android/httpclient/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/samples/client/petstore/android/httpclient/pom.xml b/samples/client/petstore/android/httpclient/pom.xml index 85f84bcccba..dd975c043a8 100644 --- a/samples/client/petstore/android/httpclient/pom.xml +++ b/samples/client/petstore/android/httpclient/pom.xml @@ -39,12 +39,12 @@ maven-surefire-plugin 2.12 - + loggerPath conf/log4j.properties - + -Xms512m -Xmx1500m methods pertest @@ -172,7 +172,7 @@ UTF-8 1.6.6 - 2.8.9 + 2.10.1 1.0.0 4.13.2 4.5.13 diff --git a/samples/client/petstore/android/httpclient/settings.gradle b/samples/client/petstore/android/httpclient/settings.gradle index 666307984ab..3bd3fb626ee 100644 --- a/samples/client/petstore/android/httpclient/settings.gradle +++ b/samples/client/petstore/android/httpclient/settings.gradle @@ -1 +1,17 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + rootProject.name = "openapi-android-client" diff --git a/samples/client/petstore/android/httpclient/src/main/java/org/openapitools/client/ApiException.java b/samples/client/petstore/android/httpclient/src/main/java/org/openapitools/client/ApiException.java index 2e0db8b1bf7..86fb1b18ab7 100644 --- a/samples/client/petstore/android/httpclient/src/main/java/org/openapitools/client/ApiException.java +++ b/samples/client/petstore/android/httpclient/src/main/java/org/openapitools/client/ApiException.java @@ -38,4 +38,12 @@ public class ApiException extends Exception { public void setMessage(String message) { this.message = message; } + + @Override + public String toString() { + return "ApiException{" + + "code=" + code + + ", message=" + message + + '}'; + } } diff --git a/samples/client/petstore/android/httpclient/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/android/httpclient/src/main/java/org/openapitools/client/api/PetApi.java index 361994a058f..9bad358c49f 100644 --- a/samples/client/petstore/android/httpclient/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/android/httpclient/src/main/java/org/openapitools/client/api/PetApi.java @@ -22,6 +22,7 @@ import java.util.*; import org.openapitools.client.model.ApiResponse; import java.io.File; +import java.util.*; import org.openapitools.client.model.Pet; import org.apache.http.entity.mime.MultipartEntityBuilder; diff --git a/samples/client/petstore/android/volley/.openapi-generator/FILES b/samples/client/petstore/android/volley/.openapi-generator/FILES index 2b570751c94..61db245e598 100644 --- a/samples/client/petstore/android/volley/.openapi-generator/FILES +++ b/samples/client/petstore/android/volley/.openapi-generator/FILES @@ -16,6 +16,7 @@ gradle/wrapper/gradle-wrapper.properties gradlew gradlew.bat pom.xml +settings.gradle src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiException.java src/main/java/org/openapitools/client/ApiInvoker.java diff --git a/samples/client/petstore/android/volley/.openapi-generator/VERSION b/samples/client/petstore/android/volley/.openapi-generator/VERSION index 5f68295fc19..7e7b8b9bc73 100644 --- a/samples/client/petstore/android/volley/.openapi-generator/VERSION +++ b/samples/client/petstore/android/volley/.openapi-generator/VERSION @@ -1 +1 @@ -6.0.0-SNAPSHOT \ No newline at end of file +7.7.0-SNAPSHOT diff --git a/samples/client/petstore/android/volley/README.md b/samples/client/petstore/android/volley/README.md index d4f8c7a7f17..0246a5e12da 100644 --- a/samples/client/petstore/android/volley/README.md +++ b/samples/client/petstore/android/volley/README.md @@ -117,13 +117,6 @@ Class | Method | HTTP request | Description ## Documentation for Authorization Authentication schemes defined for the API: -### api_key - -- **Type**: API key - -- **API key parameter name**: api_key -- **Location**: HTTP header - ### petstore_auth @@ -134,6 +127,13 @@ Authentication schemes defined for the API: - write:pets: modify pets in your account - read:pets: read your pets +### api_key + +- **Type**: API key + +- **API key parameter name**: api_key +- **Location**: HTTP header + ## Recommendation diff --git a/samples/client/petstore/android/volley/build.gradle b/samples/client/petstore/android/volley/build.gradle index 7572522ee9f..d8c12256ab4 100644 --- a/samples/client/petstore/android/volley/build.gradle +++ b/samples/client/petstore/android/volley/build.gradle @@ -1,38 +1,15 @@ -group = 'org.openapitools' -project.version = '1.0.0' - -buildscript { - repositories { - mavenLocal() - google() - maven { - url 'https://dl.google.com/dl/android/maven2' - } - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.2.+' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' - } +plugins { + id 'com.android.library' version '8.0.0' + id 'maven-publish' } -allprojects { - repositories { - google() - jcenter() - } -} - - -apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' - android { - compileSdkVersion 26 - buildToolsVersion '28.0.3' + namespace "org.openapitools.client" + compileSdkVersion 33 + buildToolsVersion '34.0.0' defaultConfig { minSdkVersion 14 - targetSdkVersion 26 + targetSdkVersion 33 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -41,25 +18,24 @@ android { lintOptions { abortOnError false } - - // Rename the aar correctly - libraryVariants.all { variant -> - variant.outputs.all { output -> - if (outputFile != null && outputFileName.endsWith('.aar')) { - outputFileName = "${archivesBaseName}-${version}.aar" - } - } + packagingOptions { + resources.excludes += "META-INF/DEPENDENCIES" } - testOptions { unitTests.returnDefaultValues = true } + publishing { + singleVariant('release') { + withSourcesJar() + } + } } ext { swagger_annotations_version = "1.6.6" - gson_version = "2.8.9" - httpmime_version = "4.5.13" + gson_version = "2.10.1" + httpcore_version = "4.4.16" + httpmime_version = "4.5.14" volley_version = "1.2.1" junit_version = "4.13.2" robolectric_version = "4.5.1" @@ -69,30 +45,28 @@ ext { dependencies { implementation "io.swagger:swagger-annotations:$swagger_annotations_version" implementation "com.google.code.gson:gson:$gson_version" - implementation "org.apache.httpcomponents:httpmime:$httpmime_version" + implementation ("org.apache.httpcomponents:httpcore:$httpcore_version") { + exclude(group: "org.apache.httpcomponents", module: "httpclient") + } + implementation ("org.apache.httpcomponents:httpmime:$httpmime_version") { + exclude(group: "org.apache.httpcomponents", module: "httpclient") + } implementation "com.android.volley:volley:${volley_version}" testImplementation "junit:junit:$junit_version" testImplementation "org.robolectric:robolectric:${robolectric_version}" testImplementation "net.jodah:concurrentunit:${concurrent_unit_version}" } -afterEvaluate { - android.libraryVariants.all { variant -> - def task = project.tasks.create "jar${variant.name.capitalize()}", Jar - task.description = "Create jar artifact for ${variant.name}" - task.dependsOn variant.javaCompile - task.from variant.javaCompile.destinationDir - task.destinationDir = project.file("${project.buildDir}/outputs/jar") - task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" - artifacts.add('archives', task); +publishing { + publications { + release(MavenPublication) { + groupId = 'org.openapitools' + artifactId = 'petstore-android-volley' + version = '1.0.0' + + afterEvaluate { + from components.release + } + } } } - -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -artifacts { - archives sourcesJar -} diff --git a/samples/client/petstore/android/volley/gradle.properties b/samples/client/petstore/android/volley/gradle.properties new file mode 100644 index 00000000000..24083f932f1 --- /dev/null +++ b/samples/client/petstore/android/volley/gradle.properties @@ -0,0 +1,15 @@ +## For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx1024m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects +# org.gradle.parallel=true +#Sun Jun 16 04:30:24 ART 2024 +#android.enableJetifier=true +#android.useAndroidX=true diff --git a/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties index 4d9ca164914..d951fac2bf3 100644 --- a/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties +++ b/samples/client/petstore/android/volley/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/samples/client/petstore/android/volley/pom.xml b/samples/client/petstore/android/volley/pom.xml index 19e2aa66a4b..83498b55469 100644 --- a/samples/client/petstore/android/volley/pom.xml +++ b/samples/client/petstore/android/volley/pom.xml @@ -54,8 +54,8 @@ UTF-8 1.6.6 - 4.5.13 - 2.8.9 + 4.5.14 + 2.10.1 1.2.1 4.1.1.4 diff --git a/samples/client/petstore/android/volley/settings.gradle b/samples/client/petstore/android/volley/settings.gradle new file mode 100644 index 00000000000..3d30c1ca105 --- /dev/null +++ b/samples/client/petstore/android/volley/settings.gradle @@ -0,0 +1,17 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "petstore-android-volley" diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiException.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiException.java index 2f57c83eeb7..e22aa161ee1 100644 --- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiException.java +++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiException.java @@ -58,4 +58,12 @@ public class ApiException extends Exception { public void setMessage(String message) { this.message = message; } + + @Override + public String toString() { + return "ApiException{" + + "code=" + code + + ", message=" + message + + '}'; + } } diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiInvoker.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiInvoker.java index 9ff0422de5f..be0cffeaffa 100644 --- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiInvoker.java +++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/ApiInvoker.java @@ -203,9 +203,9 @@ public class ApiInvoker { // Setup authentications (key: authentication name, value: authentication). INSTANCE.authentications = new HashMap(); - INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key")); // TODO: comment out below as OAuth does not exist //INSTANCE.authentications.put("petstore_auth", new OAuth()); + INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key")); // Prevent the authentications from being modified. INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications); } diff --git a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/PetApi.java index a80910cd4c8..d7a596d46ee 100644 --- a/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/android/volley/src/main/java/org/openapitools/client/api/PetApi.java @@ -25,6 +25,7 @@ import com.android.volley.VolleyError; import org.openapitools.client.model.ApiResponse; import java.io.File; +import java.util.*; import org.openapitools.client.model.Pet; import org.apache.http.HttpEntity;