Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2535,6 +2535,10 @@ project(':connect:json') {
}

project(':connect:runtime') {
configurations {
swagger
}

archivesBaseName = "connect-runtime"

dependencies {
Expand Down Expand Up @@ -2564,7 +2568,9 @@ project(':connect:runtime') {
implementation libs.mavenArtifact
implementation libs.swaggerAnnotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this to be implementation or can it be swagger too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave this a try but it wasn't successful. We still need the annotations at compile time since they're used to decorate our REST resource classes, like here:

@GET
@Path("/")
@Operation(summary = "List all active connectors")
public Response listConnectors(
final @Context UriInfo uriInfo,
final @Context HttpHeaders headers
) {


compileOnly libs.swaggerJaxrs2
// We use this library to generate OpenAPI docs for the REST API, but we don't want or need it at compile
// or run time. So, we add it to a separate configuration, which we use later on during docs generation
swagger libs.swaggerJaxrs2

testImplementation project(':clients').sourceSets.test.output
testImplementation project(':core')
Expand Down Expand Up @@ -2653,9 +2659,9 @@ project(':connect:runtime') {
}

task genConnectOpenAPIDocs(type: io.swagger.v3.plugins.gradle.tasks.ResolveTask, dependsOn: setVersionInOpenAPISpec) {
classpath = sourceSets.main.compileClasspath + sourceSets.main.runtimeClasspath
classpath = sourceSets.main.runtimeClasspath
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this assignment at all or can we just inline it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plugin requires the classpath field to be set.

I also tried this:

classpath = sourceSets.main.runtimeClasspath + configurations.swagger.asCollection()

buildClasspath = classpath

which led to a lot of these warnings:

Gradle detected a problem with the following location... Reason: Task ':connect:runtime:genConnectOpenAPIDocs' uses this output of task ':connect:runtime:processResources' without declaring an explicit or implicit dependency.

Based on discussion in the PR that introduced OpenAPI docs generation for Connect, it appears that setting classpath to sourceSets.main.runtimeClasspath creates some implicit dependencies for the genConnectOpenAPIDocs task that fix these warnings.


buildClasspath = classpath
buildClasspath = classpath + configurations.swagger.asCollection()
outputFileName = 'connect_rest'
outputFormat = 'YAML'
prettyPrint = 'TRUE'
Expand Down