forked from apereo/cas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspringboot.gradle
91 lines (80 loc) · 2.92 KB
/
springboot.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import org.apache.tools.ant.taskdefs.condition.Os
if (project.ext.forceBootifulArtifact || (!rootProject.publishReleases && !rootProject.publishSnapshots && !rootProject.skipBootifulArtifact)) {
logger.info "Applying Spring Boot plugin to bootify web application artifact for project $project.name..."
apply plugin: "org.springframework.boot"
sourceSets {
bootRun {
resources {
}
}
}
springBoot {
mainClassName = project.ext.mainClassName
buildInfo()
}
if (plugins.hasPlugin("war")) {
javadoc {
enabled false
}
bootWar {
mainClassName = project.ext.mainClassName
manifest {
attributes(
"Automatic-Module-Name": project.name,
"Implementation-Title": project.name,
"Implementation-Vendor": project.group,
"Created-By": project.group,
"Implementation-Date": java.time.ZonedDateTime.now(),
"Specification-Version": rootProject.currentRevision,
"Implementation-Version": project.version)
}
from "${buildDir}/resources/main", { into "WEB-INF/classes" }
launchScript()
}
} else {
bootJar {
mainClassName = project.ext.mainClassName
from "${buildDir}/resources/main", { into "WEB-INF/classes" }
launchScript()
}
}
bootRun {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
dependsOn pathingJar
doFirst {
classpath = files("$buildDir/classes/main", "$buildDir/resources/main", pathingJar.archivePath)
}
}
sourceResources sourceSets.bootRun
systemProperties = System.properties
def list = []
list.add("-XX:TieredStopAtLevel=1")
list.add("-Xverify:none")
if (rootProject.enableRemoteDebugging) {
def port = findAvailableTcpPort(5000..5010)
if (port > 0) {
println "Listening on port ${port} for remote debugging requests"
list.add("-Xrunjdwp:transport=dt_socket,address=${port},server=y,suspend=${rootProject.remoteDebuggingSuspend}")
}
}
jvmArgs = list
}
} else {
logger.info """
Ignoring application of Spring Boot plugin, since the build is preparing to publish SNAPSHOTs or releases,
or the build is signaled to skip the plugin explicitly.
"""
}
int findAvailableTcpPort(List<Integer> portRange) {
for (int port : portRange) {
try {
logger.debug "Checking port ${port}"
def serverSocket = new ServerSocket(port)
serverSocket.close()
return port
} catch (Exception e) {
logger.debug "Port ${port} is not available: ${e.message}"
}
}
return -1
}