forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
96 lines (85 loc) · 2.22 KB
/
build.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
92
93
94
95
96
import org.springframework.boot.gradle.tasks.bundling.BootJar
import org.springframework.boot.gradle.tasks.bundling.BootWar
plugins {
id "java"
id "org.springframework.boot"
id "war"
}
apply plugin: "io.spring.dependency-management"
repositories {
maven { url "file:${rootDir}/../test-repository"}
mavenCentral()
maven {
url "https://repo.spring.io/milestone"
content {
excludeGroup "org.springframework.boot"
}
}
maven {
url "https://repo.spring.io/snapshot"
content {
excludeGroup "org.springframework.boot"
}
}
}
configurations {
app {
extendsFrom(configurations.runtimeClasspath)
}
jetty {
extendsFrom(app)
}
tomcat {
extendsFrom(app)
}
undertow {
extendsFrom(app)
}
}
dependencyManagement {
jetty {
dependencies {
dependency "jakarta.servlet:jakarta.servlet-api:5.0.0"
}
}
}
tasks.register("resourcesJar", Jar) { jar ->
def nested = project.resources.text.fromString("nested")
from(nested) {
into "META-INF/resources/"
rename (".*", "nested-meta-inf-resource.txt")
}
if (!isWindows()) {
def encodedName = project.resources.text.fromString("encoded-name")
from(encodedName) {
into "META-INF/resources/"
rename (".*", 'nested-reserved-!#\\$%&()*+,:=?@[]-meta-inf-resource.txt')
}
}
classifier = 'resources'
}
dependencies {
compileOnly("org.eclipse.jetty:jetty-server")
compileOnly("org.springframework:spring-web")
implementation("org.springframework.boot:spring-boot-starter")
app(files(resourcesJar))
app(files(sourceSets.main.output))
app("org.springframework:spring-web")
jetty("org.springframework.boot:spring-boot-starter-jetty")
tomcat("org.springframework.boot:spring-boot-starter-tomcat")
undertow("org.springframework.boot:spring-boot-starter-undertow")
}
def boolean isWindows() {
return File.separatorChar == '\\';
}
["jetty", "tomcat", "undertow"].each { webServer ->
def configurer = { task ->
task.dependsOn resourcesJar
task.mainClass = "com.example.ResourceHandlingApplication"
task.classpath = configurations.getByName(webServer)
task.classifier = webServer
task.targetJavaVersion = project.getTargetCompatibility()
}
tasks.register("${webServer}BootJar", BootJar, configurer)
tasks.register("${webServer}BootWar", BootWar, configurer)
}