Skip to content

Kotlin gradle integration #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mdibaiee opened this issue Apr 16, 2021 · 3 comments
Closed

Kotlin gradle integration #19

mdibaiee opened this issue Apr 16, 2021 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@mdibaiee
Copy link

mdibaiee commented Apr 16, 2021

Hello!

While trying to integrate your project (it's wonderful by the way! great job!), we realised that it's not easy to integrate it with a Kotlin gradle DSL.

In order to add a processor, I had to do this:

openapiProcessor {
    apiPath("$projectDir/src/main/resources/openapi.yaml")

    val p = com.github.hauner.openapi.gradle.Processor("spring")
    p.processor("io.openapiprocessor:openapi-processor-spring:2021.3")
    p.targetDir("$projectDir/build/openapi")
    p.other.put("mapping", "$projectDir/src/main/resources/openapi-mapping.yaml")

    processors.put("spring", p)
}

Apparently the methodMissing method that you have does not work properly in Kotlin DSL, and using a spring { processor } does not work unfortunately.

@hauner hauner added this to the next milestone Apr 16, 2021
@hauner
Copy link
Member

hauner commented Apr 16, 2021

yes, that doesn't look very intuitive.

Thanks for reporting and the praise :-)

hauner added a commit that referenced this issue Apr 17, 2021
hauner added a commit that referenced this issue Apr 18, 2021
hauner added a commit that referenced this issue Apr 18, 2021
@hauner hauner added the enhancement New feature or request label Apr 20, 2021
@hauner hauner modified the milestones: next, 2021.3 Apr 20, 2021
@hauner
Copy link
Member

hauner commented Apr 24, 2021

just released 2021.3, you can now do this

// build.gradle.kts

openapiProcessor {
    apiPath("${projectDir}/src/api/openapi.yaml")

    process("spring") {
        processor("io.openapiprocessor:openapi-processor-spring:<version>")
        targetDir("${projectDir}/build/openapi")
        prop("mapping", "${projectDir}/src/api/mapping.yaml")
    }

    process("json") {
        processor("io.openapiprocessor:openapi-processor-json:<version>")
        targetDir("${buildDir}/json")
    }
}

.. unfortunately this does NOT seem to work (the integration test fails) with gradle older than 6.5. Which is strange because I can use the new methods in a groovy dsl and versions older than 6.5.

@hauner hauner closed this as completed Apr 24, 2021
@mdibaiee
Copy link
Author

Thank you @hauner !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants