Skip to content

Improve support for standalone mode #57

Closed
@georgeharley

Description

@georgeharley

This relates to issue #34

My Spring Boot application uses a backend PostgreSQL database. When the "test" profile is active it uses an embedded H2 database driver rather than the PostgreSQL one. Hence, the H2 driver is a testImplementation dependency.

When the generateOpenApiDocs task is run (either on my laptop or in a CI pipeline) it would be preferable to stick with the embedded H2 rather than requiring some remote PostgreSQL database server. Supplying -Dspring.profiles.active=test in the task's forkProperties makes that possible.

When the generateOpenApiDocs task in introduced into the CI build it always fails to start the Boot application because the H2 driver class can't be found. That's because - being a testImplementation dependency - it is not included in the assembled Spring Boot Jar. In order for the task to work the H2 driver Jar needs to be added to the Spring Boot application's runtime classpath. But because the task runs the Boot application using the java -jar command I can't find a way to accomplish this unless test dependencies are added to the Boot Jar.

To overcome this problem I'd like to propose that the generateOpenApiDocs task runs the Boot application using the java -cp command and the Spring Boot PropertiesLauncher feature.

AFAICT the proposed change would have no impact on existing uses of the plugin but would provide an opportunity to make use of PropertiesLauncher properties to specify additions to the runtime classpath with -Dloader.path=... as one of the forkProperties.

Happy to supply a PR for consideration in order to show the code changes that have made the above suggestion work in my local environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions