Skip to content

Commit 6c5e1e1

Browse files
committed
code review
1 parent aab592d commit 6c5e1e1

File tree

2 files changed

+59
-45
lines changed

2 files changed

+59
-45
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group = "org.springdoc"
12-
version = "1.3.4-SNAPSHOT"
12+
version = "1.3.4"
1313

1414
sonarqube {
1515
properties {

src/main/kotlin/org/springdoc/openapi/gradle/plugin/OpenApiGradlePlugin.kt

Lines changed: 58 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,63 @@ import org.gradle.api.logging.Logging
99
import org.springframework.boot.gradle.tasks.run.BootRun
1010

1111
open class OpenApiGradlePlugin : Plugin<Project> {
12-
private val logger = Logging.getLogger(OpenApiGradlePlugin::class.java)
13-
14-
override fun apply(project: Project) {
15-
// Run time dependency on the following plugins
16-
project.plugins.apply(SPRING_BOOT_PLUGIN)
17-
project.plugins.apply(EXEC_FORK_PLUGIN)
18-
19-
project.extensions.create(EXTENSION_NAME, OpenApiExtension::class.java, project)
20-
21-
project.afterEvaluate {
22-
// The task, used to run the Spring Boot application (`bootRun`)
23-
val bootRunTask = project.tasks.named(SPRING_BOOT_RUN_TASK_NAME)
24-
// The task, used to resolve the application's main class (`bootRunMainClassName`)
25-
val bootRunMainClassNameTask = project.tasks.named(SPRING_BOOT_RUN_MAIN_CLASS_NAME_TASK_NAME)
26-
27-
// Create a forked version spring boot run task
28-
val forkedSpringBoot =
29-
project.tasks.register(FORKED_SPRING_BOOT_RUN_TASK_NAME, JavaExecFork::class.java) { fork ->
30-
fork.dependsOn(bootRunMainClassNameTask)
31-
32-
fork.onlyIf {
33-
val bootRun = bootRunTask.get() as BootRun
34-
35-
// copy all system properties, excluding those starting with `java.class.path`
36-
fork.systemProperties =
37-
bootRun.systemProperties.filter { !it.key.startsWith(CLASS_PATH_PROPERTY_NAME) }
38-
39-
fork.workingDir = bootRun.workingDir
40-
fork.args = bootRun.args?.toMutableList() ?: mutableListOf()
41-
fork.classpath = bootRun.classpath
42-
fork.main = bootRun.mainClass.get()
43-
fork.jvmArgs = bootRun.jvmArgs
44-
fork.environment = bootRun.environment
45-
if(org.gradle.internal.jvm.Jvm.current().toString().startsWith("1.8"))
12+
private val logger = Logging.getLogger(OpenApiGradlePlugin::class.java)
13+
14+
override fun apply(project: Project) {
15+
// Run time dependency on the following plugins
16+
project.plugins.apply(SPRING_BOOT_PLUGIN)
17+
project.plugins.apply(EXEC_FORK_PLUGIN)
18+
19+
project.extensions.create(EXTENSION_NAME, OpenApiExtension::class.java, project)
20+
21+
project.afterEvaluate {
22+
// The task, used to run the Spring Boot application (`bootRun`)
23+
val bootRunTask = project.tasks.named(SPRING_BOOT_RUN_TASK_NAME)
24+
// The task, used to resolve the application's main class (`bootRunMainClassName`)
25+
val bootRunMainClassNameTask =
26+
project.tasks.named(SPRING_BOOT_RUN_MAIN_CLASS_NAME_TASK_NAME)
27+
28+
// Create a forked version spring boot run task
29+
val forkedSpringBoot =
30+
project.tasks.register(
31+
FORKED_SPRING_BOOT_RUN_TASK_NAME,
32+
JavaExecFork::class.java
33+
) { fork ->
34+
fork.dependsOn(bootRunMainClassNameTask)
35+
36+
fork.onlyIf {
37+
val bootRun = bootRunTask.get() as BootRun
38+
39+
// copy all system properties, excluding those starting with `java.class.path`
40+
fork.systemProperties =
41+
bootRun.systemProperties.filter {
42+
!it.key.startsWith(
43+
CLASS_PATH_PROPERTY_NAME
44+
)
45+
}
46+
47+
fork.workingDir = bootRun.workingDir
48+
fork.args = bootRun.args?.toMutableList() ?: mutableListOf()
49+
fork.classpath = bootRun.classpath
50+
fork.main = bootRun.mainClass.get()
51+
fork.jvmArgs = bootRun.jvmArgs
52+
fork.environment = bootRun.environment
53+
if (org.gradle.internal.jvm.Jvm.current().toString()
54+
.startsWith("1.8")
55+
) {
4656
fork.killDescendants = false
47-
true
48-
}
49-
}
50-
51-
// This is my task. Before I can run it I have to run the dependent tasks
52-
project.tasks.register(OPEN_API_TASK_NAME, OpenApiGeneratorTask::class.java) { openApiGenTask ->
53-
openApiGenTask.dependsOn(forkedSpringBoot)
54-
}
55-
}
56-
}
57+
}
58+
true
59+
}
60+
}
61+
62+
// This is my task. Before I can run it I have to run the dependent tasks
63+
project.tasks.register(
64+
OPEN_API_TASK_NAME,
65+
OpenApiGeneratorTask::class.java
66+
) { openApiGenTask ->
67+
openApiGenTask.dependsOn(forkedSpringBoot)
68+
}
69+
}
70+
}
5771
}

0 commit comments

Comments
 (0)