mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
exclude content of inner modules
This commit is contained in:
@@ -11,6 +11,7 @@ class Module extends LazyInitializeableObject implements ClasspathItem {//}, Com
|
||||
Sdk sdk;
|
||||
|
||||
private List<ModuleDependency> dependencies = []
|
||||
List contentRoots = []
|
||||
List sourceRoots = []
|
||||
List testRoots = []
|
||||
List excludes = []
|
||||
@@ -54,6 +55,10 @@ class Module extends LazyInitializeableObject implements ClasspathItem {//}, Com
|
||||
dependencies << new ModuleDependency(new ModuleSourceEntry(module: this), PredefinedDependencyScopes.COMPILE, true)
|
||||
}
|
||||
|
||||
meta.content = {Object[] arg ->
|
||||
arg.each { contentRoots << it}
|
||||
}
|
||||
|
||||
meta.src = {Object[] arg ->
|
||||
arg.each { sourceRoots << it }
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.jetbrains.jps;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -17,4 +18,15 @@ public class PathUtil {
|
||||
}
|
||||
return new File(uri).getAbsolutePath();
|
||||
}
|
||||
|
||||
public static boolean isUnder(Set<File> ancestors, File file) {
|
||||
File current = file;
|
||||
while (current != null) {
|
||||
if (ancestors.contains(current)) {
|
||||
return true;
|
||||
}
|
||||
current = current.getParentFile();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ class ProjectBuilder {
|
||||
callback: callback,
|
||||
sourceFiles: sourceFiles,
|
||||
sourceRoots: chunkSources,
|
||||
excludes: chunk.excludes,
|
||||
excludes: computeExcludes(chunk.elements, chunkSources),
|
||||
classpath: chunkClasspath,
|
||||
sourceRootsFromModuleWithDependencies: sourceRootsWithDependencies,
|
||||
)
|
||||
@@ -301,7 +301,7 @@ class ProjectBuilder {
|
||||
callback: callback,
|
||||
sourceFiles: sourceFiles,
|
||||
sourceRoots: sourceRoots,
|
||||
excludes: it.excludes,
|
||||
excludes: computeExcludes([it], sourceRoots),
|
||||
classpath: chunkClasspath,
|
||||
targetFolder: createOutputFolder(it.name, it, tests),
|
||||
sourceRootsFromModuleWithDependencies: sourceRootsWithDependencies
|
||||
@@ -362,6 +362,38 @@ class ProjectBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> computeExcludes(Collection<Module> modules, List<String> sourceRoots) {
|
||||
Set<Module> otherModules = new HashSet<Module>(project.modules.values())
|
||||
otherModules.removeAll(modules)
|
||||
|
||||
Set<String> excludes = [] as Set
|
||||
modules.each {Module module ->
|
||||
excludes.addAll(module.excludes)
|
||||
}
|
||||
Set<File> sourceRootFiles = sourceRoots.collect {new File(it)} as Set
|
||||
otherModules.each {Module module ->
|
||||
module.contentRoots.each {
|
||||
if (PathUtil.isUnder(sourceRootFiles, new File(it))) {
|
||||
excludes << it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return excludes.asList()
|
||||
}
|
||||
|
||||
private Set<String> getContentRootsUnder(Set<String> root, Set<Module> modules) {
|
||||
Set<String> result = [] as Set
|
||||
modules.each {
|
||||
it.contentRoots.each {String contentRoot ->
|
||||
if (PathUtil.isUnder(root, contentRoot)) {
|
||||
result << contentRoot
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private String createOutputFolder(String name, Module module, boolean tests) {
|
||||
def dst = getProjectPaths().getModuleOutputDir(module, tests)
|
||||
if (dst == null) {
|
||||
|
||||
@@ -368,6 +368,10 @@ public class IdeaProjectLoader {
|
||||
|
||||
def srcFolderExists = componentTag.content.sourceFolder[0] != null;
|
||||
|
||||
componentTag.content.each {Node contentTag ->
|
||||
content moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(contentTag.@url))
|
||||
}
|
||||
|
||||
componentTag.content.sourceFolder.each {Node folderTag ->
|
||||
String path = moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(folderTag.@url))
|
||||
String prefix = folderTag.@packagePrefix
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.jetbrains.jps
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class OverlappingSourceRootsTest extends JpsBuildTestCase {
|
||||
public void test() throws Exception {
|
||||
doTest("testData/overlappingSourceRoots/overlappingSourceRoots.ipr", {}, {
|
||||
dir("production") {
|
||||
dir("inner") {
|
||||
dir("y") {
|
||||
file("a.properties")
|
||||
file("Class2.class")
|
||||
}
|
||||
}
|
||||
dir("overlappingSourceRoots") {
|
||||
dir("x") {
|
||||
file("MyClass.class")
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user