Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #9173
Closed
Open
Issue created Apr 05, 2021 by Administrator@rootContributor

[BUG] [Kotlin] [Gradle Plugin] [Android] Updating Gradle plugin from 5.0.0 -> 5.1.0 results in missing method

Created by: stephen-mojo

Description

I am using the OpenApiGenerator via the Gradle plugin in my Kotlin Android project. I am running into an issue updating the version of the OpenAPI Generator Gradle plugin version from 5.0.0 -> 5.1.0. When I use 5.0.0, everything works fine. When I try to update to 5.1.0, I receive the following build errors:

A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;

Unable to find method 'com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;'
com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

My build.gradle file:

buildscript {

    ext {
        epoxy_version = '4.4.2'
        fragment_version = '1.3.1'
        hilt_version = '2.33-beta'
        jetpack_hilt_version = '1.0.0-alpha03'
        kotlin_coroutines_version = '1.3.9'
        kotlin_version = '1.4.31'
        moshi_version = '1.11.0'
        navigation_version = '2.3.4'
        ok_http_version = '5.0.0-alpha.2'
        retrofit_version = '2.9.0'
        room_version = '2.2.6'
    }

    repositories {
        google()
        jcenter()
        maven { url "https://plugins.gradle.org/m2/" }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.google.gms:google-services:4.3.5"
        classpath "com.google.firebase:firebase-crashlytics-gradle:2.5.1"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_version"
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
        classpath "org.openapitools:openapi-generator-gradle-plugin:5.1.0"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url "https://zendesk.jfrog.io/zendesk/repo" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

The plugin is configured like so:

App-level build.gradle

openApiGenerate {
    generatorName = "kotlin"
    inputSpec = "$projectDir/openapi-spec.json"
    ignoreFileOverride = "$projectDir/.openapi-generator-ignore"
    outputDir = "$buildDir/generated/openapi"
    apiPackage = "com.my.example.api.service"
    modelPackage = "com.my.example.api.model"
    configFile = "$projectDir/openapi-generator-config.json"
}

openapi-generator-config.json

{
  "apiSuffix": "Service",
  "collectionType": "list",
  "enumPropertyNaming": "UPPERCASE",
  "library": "jvm-retrofit2",
  "modelMutable": "false",
  "moshiCodeGen": "true",
  "packageName": "com.my.example.api",
  "parcelizeModels": "true",
  "sortModelPropertiesByRequiredFlag": "true",
  "sortParamsByRequiredFlag": "true",
  "useCoroutines": "true",
  "typeMappings": {
    "java.net.URI": "kotlin.String"
  }
}
Suggest a fix

If I keep everything the same, but add the following Guava dependency, everything seems to work.

 dependencies {
        ...
        classpath "org.openapitools:openapi-generator-gradle-plugin:5.1.0"
        classpath "com.google.guava:guava:30.1.1-jre"
    }

The only difference is some of my generated models switch from Set attributes to List attributes. This is fine, but worth calling out. I am not an expert on Gradle and I am not quite sure how the plugin works so I am not sure if this approach is correct or if it would have any side effects. Any help is greatly appreciated.

@Parcelize
@JsonClass(generateAdapter = true)
data class LessonUpdateRequest (
    ...
    @Json(name = "instructorsAttending")
    var instructorsAttending: kotlin.collections.Set<kotlin.Long>,
    ...

turns into:

@Parcelize
@JsonClass(generateAdapter = true)
data class LessonUpdateRequest (
    ...
    @Json(name = "instructorsAttending")
    var instructorsAttending: kotlin.collections.List<kotlin.Long>,
    ...
) : Parcelable
Assignee
Assign to
Time tracking