Skip to content

Commit

Permalink
fix: copy in War Overlay Plugin (#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjagg authored Jun 23, 2023
1 parent b00bfec commit 7aad824
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package scaldingspoon.gradle

import org.gradle.api.Action
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.plugins.WarPlugin
import org.gradle.api.tasks.bundling.War

/**
* Plugin class to support WAR overlay
*/
class WarOverlayPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.plugins.apply(WarPlugin)
project.convention.plugins.warOverlay = new WarOverlayPluginConvention()

project.tasks.withType(War, new Action<War>() {
@Override
void execute(War war) {
war.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
war.doFirst {
war.classpath = war.classpath.filter { !it.name.endsWith(".war") }

war.project.configurations.runtime.each {
if (it.name.endsWith(".war")) {
def fileList = war.project.zipTree(it)
if (project.convention.plugins.warOverlay.includeWarJars) {
war.from fileList
} else {
war.from fileList.matching { exclude "**/*.jar" }
}
}
}
}
}
})
}
}

/**
* Plugin convention to configure war overlay specific parameters
*/
class WarOverlayPluginConvention {
boolean includeWarJars = false

def warOverlay(Closure c) {
c.delegate = this
c()
}

def methodMissing(String name, args) {
this."${name}" = args[0]
}
}
21 changes: 3 additions & 18 deletions overlays/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.scaldingspoon.gradle:gradle-waroverlay-plugin:${waroverlayPluginVersion}"
}
}
import scaldingspoon.gradle.WarOverlayPlugin

subprojects {

apply plugin: 'maven'
apply plugin: 'waroverlay'
apply plugin: WarOverlayPlugin
apply plugin: org.apereo.portal.start.gradle.plugins.GradleTomcatDeployPlugin

repositories {
Expand All @@ -18,15 +12,6 @@ subprojects {
maven { url "https://jitpack.io" }
}

buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.scaldingspoon.gradle:gradle-waroverlay-plugin:${waroverlayPluginVersion}"
}
}

warOverlay {
// Include the jar files in the WAR (default is false).
includeWarJars true
Expand Down

0 comments on commit 7aad824

Please sign in to comment.