Skip to content

[REQ] Allow generating only src/main/java in gradle plugin #6155

Open
@AceHack

Description

@AceHack

Is your feature request related to a problem? Please describe.

When using the gradle plugin instead of creating a whole new project for java clients, I would rather just have the code generated as a precompile step and added to the classpath like https://github.com/joelittlejohn/jsonschema2pojo handles code generation.

Describe the solution you'd like

Ability to only generate the code classes in src/main/java for java clients and then the generated classes be auto referenced in the existing gradle project that's dong the code generation.

Describe alternatives you've considered

This is able as close as I've been able to come to accomplishing that with the current plugin, but it still generates a ton of extra needed stuff like the gradle project, gradle wrapper, and a bunch of other things. I would really like to be able to generate just the source code.

in build.gradle.kts

val openApiGeneratedDir = "${project.buildDir}/generated/sources/openApi"

tasks.compileJava {
    dependsOn(tasks.openApiGenerate)
}

sourceSets.main {
    java.srcDir(openApiGeneratedDir)
}

openApiGenerate {
    inputSpec.set("https://xxx.yyy.zzz")
    validateSpec.set(true)
    generatorName.set("java")
    engine.set("mustache")
    skipOverwrite.set(false)
    outputDir.set(openApiGeneratedDir)
    apiPackage.set("datalake.subscription.api")
    invokerPackage.set("datalake.subscription.invoker")
    modelPackage.set("datalake.subscription.model")
    generateApiTests.set(false)
    generateApiDocumentation.set(false)
    generateModelTests.set(false)
    generateModelDocumentation.set(false)
    configOptions.set(mapOf(
            "java8" to "true",
            "dateLibrary" to "java8",
            "library" to "native",
            "asyncNative" to "true",
            "serializationLibrary" to "jackson"
    ))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions