mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-25934 Maven: Webapp resources filtering
store web resources configuration.
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.maven.model.impl;
|
||||
|
||||
import com.intellij.util.xmlb.annotations.AbstractCollection;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
public class MavenArtifactResourceConfiguration {
|
||||
|
||||
public String webArtifactName;
|
||||
|
||||
@Tag("web-resources")
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "resource")
|
||||
public List<ResourceRootConfiguration> webResources = new ArrayList<ResourceRootConfiguration>();
|
||||
|
||||
}
|
||||
-6
@@ -71,12 +71,6 @@ public class MavenModuleResourceConfiguration {
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "resource")
|
||||
public List<ResourceRootConfiguration> testResources = new ArrayList<ResourceRootConfiguration>();
|
||||
|
||||
public String webArtifactName;
|
||||
|
||||
@Tag("web-resources")
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "resource")
|
||||
public List<ResourceRootConfiguration> webResources = new ArrayList<ResourceRootConfiguration>();
|
||||
|
||||
public Set<String> getFilteringExcludedExtensions() {
|
||||
if (filteringExclusions.isEmpty()) {
|
||||
return MavenProjectConfiguration.DEFAULT_FILTERING_EXCLUDED_EXTENSIONS;
|
||||
|
||||
+4
@@ -49,6 +49,10 @@ public class MavenProjectConfiguration {
|
||||
@MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false, entryTagName = "maven-module", keyAttributeName = "name")
|
||||
public Map<String, MavenModuleResourceConfiguration> moduleConfigurations = new THashMap<String, MavenModuleResourceConfiguration>();
|
||||
|
||||
@Tag("web-resources")
|
||||
@MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false, entryTagName = "artifact", keyAttributeName = "name")
|
||||
public Map<String, MavenArtifactResourceConfiguration> artifactsResources = new THashMap<String, MavenArtifactResourceConfiguration>();
|
||||
|
||||
@Nullable
|
||||
public MavenModuleResourceConfiguration findProject(MavenIdBean id) {
|
||||
return getModuleConfigurationMap().get(id);
|
||||
|
||||
+18
-8
@@ -3,6 +3,7 @@ package org.jetbrains.idea.maven.project;
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerConfigurationImpl;
|
||||
import com.intellij.compiler.server.BuildManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -23,10 +24,7 @@ import org.jetbrains.idea.maven.model.MavenId;
|
||||
import org.jetbrains.idea.maven.model.MavenResource;
|
||||
import org.jetbrains.idea.maven.utils.MavenJDOMUtil;
|
||||
import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
import org.jetbrains.jps.maven.model.impl.MavenIdBean;
|
||||
import org.jetbrains.jps.maven.model.impl.MavenModuleResourceConfiguration;
|
||||
import org.jetbrains.jps.maven.model.impl.MavenProjectConfiguration;
|
||||
import org.jetbrains.jps.maven.model.impl.ResourceRootConfiguration;
|
||||
import org.jetbrains.jps.maven.model.impl.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@@ -38,6 +36,8 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class MavenResourceCompilerConfigurationGenerator {
|
||||
|
||||
private static Logger LOG = Logger.getInstance(MavenResourceCompilerConfigurationGenerator.class);
|
||||
|
||||
private static final Pattern SIMPLE_NEGATIVE_PATTERN = Pattern.compile("!\\?(\\*\\.\\w+)");
|
||||
|
||||
private final Project myProject;
|
||||
@@ -119,7 +119,7 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
addResources(resourceConfig.resources, mavenProject.getResources());
|
||||
addResources(resourceConfig.testResources, mavenProject.getTestResources());
|
||||
|
||||
addWebResources(module, resourceConfig, mavenProject);
|
||||
addWebResources(module, projectConfig, mavenProject);
|
||||
|
||||
resourceConfig.filteringExclusions.addAll(MavenProjectsTree.getFilterExclusions(mavenProject));
|
||||
|
||||
@@ -225,14 +225,24 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addWebResources(@NotNull Module module, MavenModuleResourceConfiguration moduleCfg, MavenProject mavenProject) {
|
||||
private static void addWebResources(@NotNull Module module, MavenProjectConfiguration projectCfg, MavenProject mavenProject) {
|
||||
Element warCfg = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-war-plugin");
|
||||
if (warCfg == null) return;
|
||||
|
||||
Element webResources = warCfg.getChild("webResources");
|
||||
if (webResources == null) return;
|
||||
|
||||
moduleCfg.webArtifactName = MavenUtil.getArtifactName("war", module, true);
|
||||
String webArtifactName = MavenUtil.getArtifactName("war", module, true);
|
||||
|
||||
MavenArtifactResourceConfiguration artifactResourceCfg = projectCfg.artifactsResources.get(webArtifactName);
|
||||
if (artifactResourceCfg == null) {
|
||||
artifactResourceCfg = new MavenArtifactResourceConfiguration();
|
||||
artifactResourceCfg.webArtifactName = webArtifactName;
|
||||
projectCfg.artifactsResources.put(webArtifactName, artifactResourceCfg);
|
||||
}
|
||||
else {
|
||||
LOG.error("MavenArtifactResourceConfiguration already exists.");
|
||||
}
|
||||
|
||||
for (Element resource : webResources.getChildren("resource")) {
|
||||
ResourceRootConfiguration r = new ResourceRootConfiguration();
|
||||
@@ -268,7 +278,7 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
moduleCfg.webResources.add(r);
|
||||
artifactResourceCfg.webResources.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user