Skip to content

Commit

Permalink
Merge pull request #58 from georgeharley/use-properties-launcher
Browse files Browse the repository at this point in the history
Use PropertiesLauncher feature to run Spring Boot applications
  • Loading branch information
bnasslahsen authored Aug 23, 2021
2 parents de77480 + 33ec10a commit 40f8a5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit 40f8a5a

Please sign in to comment.