spring-boot/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/spring-boot-server-tests-app/build.gradle

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

98 lines
2.7 KiB
Groovy
Raw Normal View History

/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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"
}
java {
sourceCompatibility = '17'
targetCompatibility = '17'
}
repositories {
maven { url "file:${rootDir}/../test-repository"}
mavenCentral()
spring.mavenRepositoriesExcludingBootGroup()
}
configurations {
app {
extendsFrom(configurations.runtimeClasspath)
}
jetty {
extendsFrom(app)
}
tomcat {
extendsFrom(app)
}
undertow {
extendsFrom(app)
}
}
2023-09-29 04:45:45 +08:00
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')
}
}
archiveClassifier = 'resources'
}
dependencies {
compileOnly("org.springframework:spring-web")
compileOnly("org.springframework.boot:spring-boot-jetty")
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
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")
}
static boolean isWindows() {
return File.separatorChar == '\\'
}
["jetty", "tomcat", "undertow"].each { webServer ->
2023-09-29 04:45:45 +08:00
def configurer = { task ->
task.dependsOn resourcesJar
task.mainClass = "com.example.ResourceHandlingApplication"
task.classpath = configurations.getByName(webServer)
task.archiveClassifier = webServer
task.targetJavaVersion = project.getTargetCompatibility()
}
tasks.register("${webServer}BootJar", BootJar, configurer)
tasks.register("${webServer}BootWar", BootWar, configurer)
}