diff --git a/src/main/kotlin/org/springdoc/openapi/gradle/plugin/Constants.kt b/src/main/kotlin/org/springdoc/openapi/gradle/plugin/Constants.kt index edf4455..3d914f3 100644 --- a/src/main/kotlin/org/springdoc/openapi/gradle/plugin/Constants.kt +++ b/src/main/kotlin/org/springdoc/openapi/gradle/plugin/Constants.kt @@ -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" diff --git a/src/main/kotlin/org/springdoc/openapi/gradle/plugin/OpenApiGradlePlugin.kt b/src/main/kotlin/org/springdoc/openapi/gradle/plugin/OpenApiGradlePlugin.kt index ed509bd..c5864da 100644 --- a/src/main/kotlin/org/springdoc/openapi/gradle/plugin/OpenApiGradlePlugin.kt +++ b/src/main/kotlin/org/springdoc/openapi/gradle/plugin/OpenApiGradlePlugin.kt @@ -1,3 +1,5 @@ +@file:Suppress("unused") + package org.springdoc.openapi.gradle.plugin import org.gradle.api.Plugin @@ -30,7 +32,8 @@ open class OpenApiGradlePlugin : Plugin { 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 } } @@ -56,8 +59,10 @@ open class OpenApiGradlePlugin : Plugin { 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.")