You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.0 KiB
76 lines
2.0 KiB
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" |
|
} |
|
|
|
repositories { |
|
maven { url "file:${rootDir}/../test-repository"} |
|
mavenCentral() |
|
spring.mavenRepositoriesExcludingBootGroup() |
|
} |
|
|
|
configurations { |
|
app { |
|
extendsFrom(configurations.runtimeClasspath) |
|
} |
|
jetty { |
|
extendsFrom(app) |
|
} |
|
tomcat { |
|
extendsFrom(app) |
|
} |
|
undertow { |
|
extendsFrom(app) |
|
} |
|
} |
|
|
|
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.eclipse.jetty.ee10:jetty-ee10-servlet") |
|
compileOnly("org.springframework:spring-web") |
|
|
|
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") |
|
} |
|
|
|
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.archiveClassifier = webServer |
|
task.targetJavaVersion = project.getTargetCompatibility() |
|
} |
|
tasks.register("${webServer}BootJar", BootJar, configurer) |
|
tasks.register("${webServer}BootWar", BootWar, configurer) |
|
}
|
|
|