springdoc-openapi-gradle-plugin
springdoc-openapi-gradle-plugin copied to clipboard
Add ability to run with a different classpath
I want to start the app using an in memory db, so I need to start the bootrun with e.g test classpath.
I've done many attempts to modify the classpath inside the bootRun clause in the plugin, but none of them seems to work. If there is a way already, please let me know, otherwise it would be nice to add this.
I second this. I had to create unnecessary mock components to my main classpath to get this plugin working. Test classpath already had such mocks, but they are of course inaccessible from main classpath.
I might be wrong, but isn't this already working to a certain degree? See https://github.com/springdoc/springdoc-openapi-gradle-plugin/blob/e855f9c3aeb776f3d3ef285c80aca748c5a50950/src/main/kotlin/org/springdoc/openapi/gradle/plugin/OpenApiGradlePlugin.kt#L102-L103
In my case, I want to run the app with a modified profile specifically for the doc generation and want to simply use Testcontainers as a DB replacement:
configurations {
openApiGenRuntime.extendsFrom(runtimeClasspath)
}
dependencies {
openApiGenRuntime 'org.testcontainers:postgresql'
}
openApi {
apiDocsUrl.set("http://localhost:${randPort}/api-docs")
customBootRun {
args.set(["--spring.profiles.active=gen-apidocs", "--server.port=${randPort}"])
classpath = configurations.openApiGenRuntime
}
}
Yet, I still run into problems with my modules importing dependencies from within the project (i.e. other submodules). Inspecting the forked process's classpath shows that it points to the dependencies as jars but they are not necessarily created when running this task. You can work around this again by setting classpath = sourceSets.main.compileClasspath + configurations.openApiGenRuntime
but then there might be problems with resources being imported by the dependencies (this is where I'm stuck right now).
If there's a leaner solution to this, I'd be happy to know.
@tsvendsen,
There are no plans to support such a feature.