-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: copy in War Overlay Plugin (#646)
- Loading branch information
Showing
2 changed files
with
59 additions
and
18 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
buildSrc/src/main/groovy/scaldingspoon/gradle/WarOverlayPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters