Search in sources :

Example 6 with MavenResource

use of org.jetbrains.idea.maven.model.MavenResource in project intellij-community by JetBrains.

the class MavenFoldersImporter method configSourceFolders.

private void configSourceFolders() {
    final MultiMap<JpsModuleSourceRootType<?>, String> roots = new LinkedMultiMap<>();
    roots.putValues(JavaSourceRootType.SOURCE, myMavenProject.getSources());
    roots.putValues(JavaSourceRootType.TEST_SOURCE, myMavenProject.getTestSources());
    for (MavenImporter each : MavenImporter.getSuitableImporters(myMavenProject)) {
        each.collectSourceRoots(myMavenProject, (s, type) -> roots.putValue(type, s));
    }
    for (MavenResource each : myMavenProject.getResources()) {
        roots.putValue(JavaResourceRootType.RESOURCE, each.getDirectory());
    }
    for (MavenResource each : myMavenProject.getTestResources()) {
        roots.putValue(JavaResourceRootType.TEST_RESOURCE, each.getDirectory());
    }
    addBuilderHelperPaths("add-source", roots.getModifiable(JavaSourceRootType.SOURCE));
    addBuilderHelperPaths("add-test-source", roots.getModifiable(JavaSourceRootType.TEST_SOURCE));
    List<String> addedPaths = new ArrayList<>();
    for (JpsModuleSourceRootType<?> type : roots.keySet()) {
        for (String path : roots.get(type)) {
            addSourceFolderIfNotOverlap(path, type, addedPaths);
        }
    }
}
Also used : MavenResource(org.jetbrains.idea.maven.model.MavenResource) LinkedMultiMap(com.intellij.util.containers.LinkedMultiMap) JpsModuleSourceRootType(org.jetbrains.jps.model.module.JpsModuleSourceRootType) ArrayList(java.util.ArrayList)

Example 7 with MavenResource

use of org.jetbrains.idea.maven.model.MavenResource in project intellij-community by JetBrains.

the class MavenResourceCompilerConfigurationGenerator method addResources.

private static void addResources(final List<ResourceRootConfiguration> container, @NotNull Collection<MavenResource> resources) {
    for (MavenResource resource : resources) {
        final String dir = resource.getDirectory();
        if (dir == null) {
            continue;
        }
        final ResourceRootConfiguration props = new ResourceRootConfiguration();
        props.directory = FileUtil.toSystemIndependentName(dir);
        final String target = resource.getTargetPath();
        props.targetPath = target != null ? FileUtil.toSystemIndependentName(target) : null;
        props.isFiltered = resource.isFiltered();
        props.includes.clear();
        for (String include : resource.getIncludes()) {
            props.includes.add(include.trim());
        }
        props.excludes.clear();
        for (String exclude : resource.getExcludes()) {
            props.excludes.add(exclude.trim());
        }
        container.add(props);
    }
}
Also used : MavenResource(org.jetbrains.idea.maven.model.MavenResource)

Aggregations

MavenResource (org.jetbrains.idea.maven.model.MavenResource)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 CompilerConfiguration (com.intellij.compiler.CompilerConfiguration)1 Module (com.intellij.openapi.module.Module)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 LinkedMultiMap (com.intellij.util.containers.LinkedMultiMap)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Pattern (java.util.regex.Pattern)1 DirectoryScanner (org.codehaus.plexus.util.DirectoryScanner)1 JpsModuleSourceRootType (org.jetbrains.jps.model.module.JpsModuleSourceRootType)1