Skip to content

Use PropertiesLauncher feature to run Spring Boot applications #58

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

Merged
merged 1 commit into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ const val DEFAULT_WAIT_TIME_IN_SECONDS = 30

const val SPRING_BOOT_PLUGIN = "org.springframework.boot"
const val PROCESS_PLUGIN = "com.github.johnrengelman.processes"

const val PROPS_LAUNCHER_CLASS = "org.springframework.boot.loader.PropertiesLauncher"
const val CLASS_PATH_PROPERTY_NAME = "java.class.path"
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("unused")

package org.springdoc.openapi.gradle.plugin

import org.gradle.api.Plugin
Expand Down Expand Up @@ -30,7 +32,8 @@ open class OpenApiGradlePlugin : Plugin<Project> {

fork.onlyIf {
val bootJar = bootJarTask.get().outputs.files.first()
fork.commandLine = listOf("java", "-jar") + extractProperties(extension.forkProperties) + listOf("$bootJar")
fork.commandLine = listOf("java", "-cp") +
listOf("$bootJar") + extractProperties(extension.forkProperties) + listOf(PROPS_LAUNCHER_CLASS)
true
}
}
Expand All @@ -56,8 +59,10 @@ open class OpenApiGradlePlugin : Plugin<Project> {
is String -> element
.split("-D")
.filter { it.isNotEmpty() }
.filterNot { it.startsWith(CLASS_PATH_PROPERTY_NAME, true) }
.map { "-D${it.trim()}" }
is Properties -> element
.filterNot { it.key.toString().startsWith(CLASS_PATH_PROPERTY_NAME, true) }
.map { "-D${it.key}=${it.value}" }
else -> {
logger.warn("Failed to use the value set for 'forkProperties'. Only String and Properties objects are supported.")
Expand Down