mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-122132 Maven: filtering of deployment descriptors
support filteringDeploymentDescriptors option
This commit is contained in:
+47
-34
@@ -234,8 +234,10 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
Element warCfg = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-war-plugin");
|
||||
if (warCfg == null) return;
|
||||
|
||||
boolean filterWebXml = Boolean.parseBoolean(warCfg.getChildTextTrim("filteringDeploymentDescriptors"));
|
||||
Element webResources = warCfg.getChild("webResources");
|
||||
if (webResources == null) return;
|
||||
|
||||
if (webResources == null && !filterWebXml) return;
|
||||
|
||||
String webArtifactName = MavenUtil.getArtifactName("war", module, true);
|
||||
|
||||
@@ -250,40 +252,51 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
LOG.error("MavenArtifactResourceConfiguration already exists.");
|
||||
}
|
||||
|
||||
for (Element resource : webResources.getChildren("resource")) {
|
||||
if (webResources != null) {
|
||||
for (Element resource : webResources.getChildren("resource")) {
|
||||
ResourceRootConfiguration r = new ResourceRootConfiguration();
|
||||
String directory = resource.getChildTextTrim("directory");
|
||||
if (StringUtil.isEmptyOrSpaces(directory)) continue;
|
||||
|
||||
if (!FileUtil.isAbsolute(directory)) {
|
||||
directory = mavenProject.getDirectory() + '/' + directory;
|
||||
}
|
||||
|
||||
r.directory = directory;
|
||||
r.isFiltered = Boolean.parseBoolean(resource.getChildTextTrim("filtering"));
|
||||
|
||||
r.targetPath = resource.getChildTextTrim("targetPath");
|
||||
|
||||
Element includes = resource.getChild("includes");
|
||||
if (includes != null) {
|
||||
for (Element include : includes.getChildren("include")) {
|
||||
String includeText = include.getTextTrim();
|
||||
if (!includeText.isEmpty()) {
|
||||
r.includes.add(includeText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Element excludes = resource.getChild("excludes");
|
||||
if (excludes != null) {
|
||||
for (Element exclude : excludes.getChildren("exclude")) {
|
||||
String excludeText = exclude.getTextTrim();
|
||||
if (!excludeText.isEmpty()) {
|
||||
r.excludes.add(excludeText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
artifactResourceCfg.webResources.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
if (filterWebXml) {
|
||||
ResourceRootConfiguration r = new ResourceRootConfiguration();
|
||||
String directory = resource.getChildTextTrim("directory");
|
||||
if (StringUtil.isEmptyOrSpaces(directory)) continue;
|
||||
|
||||
if (!FileUtil.isAbsolute(directory)) {
|
||||
directory = mavenProject.getDirectory() + '/' + directory;
|
||||
}
|
||||
|
||||
r.directory = directory;
|
||||
r.isFiltered = Boolean.parseBoolean(resource.getChildTextTrim("filtering"));
|
||||
|
||||
r.targetPath = resource.getChildTextTrim("targetPath");
|
||||
|
||||
Element includes = resource.getChild("includes");
|
||||
if (includes != null) {
|
||||
for (Element include : includes.getChildren("include")) {
|
||||
String includeText = include.getTextTrim();
|
||||
if (!includeText.isEmpty()) {
|
||||
r.includes.add(includeText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Element excludes = resource.getChild("excludes");
|
||||
if (excludes != null) {
|
||||
for (Element exclude : excludes.getChildren("exclude")) {
|
||||
String excludeText = exclude.getTextTrim();
|
||||
if (!excludeText.isEmpty()) {
|
||||
r.excludes.add(excludeText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
r.directory = mavenProject.getDirectory() + "/src/main/webapp";
|
||||
r.includes = Collections.singleton("WEB-INF/web.xml");
|
||||
r.isFiltered = true;
|
||||
r.targetPath = "";
|
||||
artifactResourceCfg.webResources.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user