How to publish a binary generated by OpenAPI Generator with gradle/kotlin?

1k Views Asked by At

I'm trying to create and publish binary artifacts from an OpenAPI Spec to our internal Maven Repository.

First, I'm using the "org.openapi.generator" version 5.0.0-beta2 to generate an endpoint project from a spec. For example a Kotlin Spring service. Works fine, creates an entire gradle/kotlin project, with a build.gradle.kts file and a settings.gradle file.

If I navigate to that folder I can build that project just fine. I can also call that build from my original build to first generate the code and then build it.

I just don't know how to publish it. My publishing configuration is obviously not in the generated project, nor is there a maven-publish plugin. Is there a way I can 'inject' these? Can I call some kind of 'include' on a build?

1

There are 1 best solutions below

0
On

For myself, I generate the files to $buildDir/generated/ and do what I want with the files in $buildDir/generated/src/main/kotlin from my own build script ... such as:

  • copy them to src/main/kotlin (if that's important to you),
  • compile them, jar them, publish them.

I don't really even appreciate that the openApiGenerate task went to the trouble of preparing a build.gradle file instead of a build.gradle.kts file, with arguably out-dated dependencies ... it should mind its own business.