'OpenAPI Generator gradle plugin task not executed

In my android project I am trying to include the openapi-generator plugin to generate a client. I've copied the instructions from the readme for my project. Unfortunately, the task doesen't seem to be executed.

I am new to gradle and android. So I haven't a lot of knowledge on these subjects yet.

This is the projects build.gradle file:

buildscript {
    ext {
        nav_version = '2.4.2'
    }
    dependencies {
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
        classpath "org.openapitools:openapi-generator-gradle-plugin:5.4.0"
    }
}

plugins {
    id 'com.android.application' version '7.1.3' apply false
    id 'com.android.library' version '7.1.3' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}

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

This is the build.gradle file of my module:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'androidx.navigation.safeargs.kotlin'
    id 'kotlin-kapt'
    id "org.openapi.generator"
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "..."
        minSdk 29
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
        dataBinding true
    }
    sourceSets {
        main {
            kotlin {
                srcDirs += 'build/generated/source/navigation-args/'
            }
        }
    }
}

dependencies {
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

openApiGenerate {
    generatorName = "kotlin"
    inputSpec = "$rootDir/app/src/main/assets/swagger.yml".toString()
    outputDir = "$buildDir/generated".toString()
    apiPackage = "org.openapi.example.api"
    invokerPackage = "org.openapi.example.invoker"
    modelPackage = "org.openapi.example.model"
    configOptions = [
            dateLibrary: "java8"
    ]
}

In the output of the build was no hint that the openApiGenerate task was executed and on the filesystem I didn't find the generated client. Probably there is a mistake in the configuration, but I don't know what is wrong.

Can you help me?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source