Add support for creating layered war files with Gradle
See gh-22195
This commit is contained in:
@@ -16,6 +16,7 @@ dependencies {
|
||||
implementation("com.example:library:1.0-SNAPSHOT")
|
||||
implementation("org.apache.commons:commons-lang3:3.9")
|
||||
implementation("org.springframework:spring-core:5.2.5.RELEASE")
|
||||
implementation("org.springframework.boot:spring-boot-starter-logging:2.2.0.RELEASE")
|
||||
}
|
||||
|
||||
task listLayers(type: JavaExec) {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'war'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
layered {
|
||||
application {
|
||||
intoLayer("static") {
|
||||
include "META-INF/resources/**", "resources/**", "static/**", "public/**"
|
||||
}
|
||||
intoLayer("app")
|
||||
}
|
||||
dependencies {
|
||||
intoLayer("snapshot-dependencies") {
|
||||
include "*:*:*SNAPSHOT"
|
||||
}
|
||||
intoLayer("commons-dependencies") {
|
||||
include "org.apache.commons:*"
|
||||
}
|
||||
intoLayer("dependencies")
|
||||
}
|
||||
layerOrder = ["dependencies", "commons-dependencies", "snapshot-dependencies", "static", "app"]
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "file:repository" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.example:library:1.0-SNAPSHOT")
|
||||
implementation("org.apache.commons:commons-lang3:3.9")
|
||||
implementation("org.springframework:spring-core:5.2.5.RELEASE")
|
||||
}
|
||||
|
||||
task listLayers(type: JavaExec) {
|
||||
classpath = bootWar.outputs.files
|
||||
systemProperties = [ "jarmode": "layertools" ]
|
||||
args "list"
|
||||
}
|
||||
|
||||
task extractLayers(type: JavaExec) {
|
||||
classpath = bootWar.outputs.files
|
||||
systemProperties = [ "jarmode": "layertools" ]
|
||||
args "extract"
|
||||
}
|
||||
@@ -16,3 +16,9 @@ dependencies {
|
||||
developmentOnly("commons-io:commons-io:2.6")
|
||||
implementation("commons-io:commons-io:2.6")
|
||||
}
|
||||
|
||||
bootWar {
|
||||
layered {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,3 +19,9 @@ dependencies {
|
||||
bootWar {
|
||||
classpath configurations.developmentOnly
|
||||
}
|
||||
|
||||
bootWar {
|
||||
layered {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'war'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "file:repository" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.example:library:1.0-SNAPSHOT")
|
||||
implementation("org.apache.commons:commons-lang3:3.9")
|
||||
implementation("org.springframework:spring-core:5.2.5.RELEASE")
|
||||
implementation("org.springframework.boot:spring-boot-starter-logging:2.2.0.RELEASE")
|
||||
}
|
||||
|
||||
task listLayers(type: JavaExec) {
|
||||
classpath = bootWar.outputs.files
|
||||
systemProperties = [ "jarmode": "layertools" ]
|
||||
args "list"
|
||||
}
|
||||
|
||||
task extractLayers(type: JavaExec) {
|
||||
classpath = bootWar.outputs.files
|
||||
systemProperties = [ "jarmode": "layertools" ]
|
||||
args "extract"
|
||||
}
|
||||
@@ -17,3 +17,9 @@ dependencies {
|
||||
implementation(name: "standard")
|
||||
implementation(name: "starter")
|
||||
}
|
||||
|
||||
bootWar {
|
||||
layered {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'war'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
custom
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "file:repository" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.example:library:1.0-SNAPSHOT")
|
||||
implementation("org.apache.commons:commons-lang3:3.9")
|
||||
implementation("org.springframework:spring-core:5.2.5.RELEASE")
|
||||
}
|
||||
|
||||
task listLayers(type: JavaExec) {
|
||||
classpath = bootWar.outputs.files
|
||||
systemProperties = [ "jarmode": "layertools" ]
|
||||
args "list"
|
||||
}
|
||||
|
||||
task extractLayers(type: JavaExec) {
|
||||
classpath = bootWar.outputs.files
|
||||
systemProperties = [ "jarmode": "layertools" ]
|
||||
args "extract"
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'war'
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'java'
|
||||
group = 'org.example.projects'
|
||||
version = '1.2.3'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
layered {
|
||||
application {
|
||||
intoLayer("static") {
|
||||
include "META-INF/resources/**", "resources/**", "static/**", "public/**"
|
||||
}
|
||||
intoLayer("app")
|
||||
}
|
||||
dependencies {
|
||||
intoLayer("snapshot-dependencies") {
|
||||
include "*:*:*SNAPSHOT"
|
||||
excludeProjectDependencies()
|
||||
}
|
||||
intoLayer("subproject-dependencies") {
|
||||
includeProjectDependencies()
|
||||
}
|
||||
intoLayer("commons-dependencies") {
|
||||
include "org.apache.commons:*"
|
||||
}
|
||||
intoLayer("dependencies")
|
||||
}
|
||||
layerOrder = ["dependencies", "commons-dependencies", "snapshot-dependencies", "subproject-dependencies", "static", "app"]
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "file:repository" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(':alpha'))
|
||||
implementation(project(':bravo'))
|
||||
implementation("com.example:library:1.0-SNAPSHOT")
|
||||
implementation("org.apache.commons:commons-lang3:3.9")
|
||||
implementation("org.springframework:spring-core:5.2.5.RELEASE")
|
||||
}
|
||||
|
||||
task listLayers(type: JavaExec) {
|
||||
classpath = bootWar.outputs.files
|
||||
systemProperties = [ "jarmode": "layertools" ]
|
||||
args "list"
|
||||
}
|
||||
|
||||
task extractLayers(type: JavaExec) {
|
||||
classpath = bootWar.outputs.files
|
||||
systemProperties = [ "jarmode": "layertools" ]
|
||||
args "extract"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'war'
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'java'
|
||||
group = 'org.example.projects'
|
||||
version = '1.2.3'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "file:repository" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(':alpha'))
|
||||
implementation(project(':bravo'))
|
||||
implementation("com.example:library:1.0-SNAPSHOT")
|
||||
implementation("org.apache.commons:commons-lang3:3.9")
|
||||
implementation("org.springframework:spring-core:5.2.5.RELEASE")
|
||||
}
|
||||
|
||||
task listLayers(type: JavaExec) {
|
||||
classpath = bootWar.outputs.files
|
||||
systemProperties = [ "jarmode": "layertools" ]
|
||||
args "list"
|
||||
}
|
||||
|
||||
task extractLayers(type: JavaExec) {
|
||||
classpath = bootWar.outputs.files
|
||||
systemProperties = [ "jarmode": "layertools" ]
|
||||
args "extract"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'war'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
layered {
|
||||
{layerTools}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'war'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
layered {
|
||||
{layerEnablement}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'war'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
{layered}
|
||||
}
|
||||
Reference in New Issue
Block a user