mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Gradle: gradle source set can have multiple output directories for sources since gradle 4.0 (IDEA-176985)
This commit is contained in:
+8
-10
@@ -46,6 +46,7 @@ import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.net.HttpConfigurable;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import groovy.lang.GroovyObject;
|
||||
@@ -393,6 +394,11 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver
|
||||
processSourceSets(resolverCtx, gradleModule, externalProject, ideModule, new SourceSetsProcessor() {
|
||||
@Override
|
||||
public void process(@NotNull DataNode<? extends ModuleData> dataNode, @NotNull ExternalSourceSet sourceSet) {
|
||||
MultiMap<ExternalSystemSourceType, String> gradleOutputMap = dataNode.getUserData(GradleProjectResolver.GRADLE_OUTPUTS);
|
||||
if (gradleOutputMap == null) {
|
||||
gradleOutputMap = MultiMap.create();
|
||||
dataNode.putUserData(GradleProjectResolver.GRADLE_OUTPUTS, gradleOutputMap);
|
||||
}
|
||||
for (Map.Entry<IExternalSystemSourceType, ExternalSourceDirectorySet> directorySetEntry : sourceSet.getSources().entrySet()) {
|
||||
ExternalSystemSourceType sourceType = ExternalSystemSourceType.from(directorySetEntry.getKey());
|
||||
ExternalSourceDirectorySet sourceDirectorySet = directorySetEntry.getValue();
|
||||
@@ -402,21 +408,13 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver
|
||||
moduleData.setCompileOutputPath(sourceType, outputDir.getAbsolutePath());
|
||||
moduleData.setInheritProjectCompileOutputPath(sourceDirectorySet.isCompilerOutputPathInherited());
|
||||
|
||||
|
||||
String gradleOutputPath = moduleData.getCompileOutputPath(sourceType);
|
||||
for (File gradleOutputDir : sourceDirectorySet.getGradleOutputDirs()) {
|
||||
String gradleOutputPath = ExternalSystemApiUtil.toCanonicalPath(gradleOutputDir.getAbsolutePath());
|
||||
gradleOutputMap.putValue(sourceType, gradleOutputPath);
|
||||
if(!gradleOutputDir.getPath().equals(outputDir.getPath())) {
|
||||
gradleOutputPath = ExternalSystemApiUtil.toCanonicalPath(gradleOutputDir.getAbsolutePath());
|
||||
moduleOutputsMap.put(gradleOutputPath, Pair.create(moduleData.getId(), sourceType));
|
||||
}
|
||||
}
|
||||
|
||||
Map<ExternalSystemSourceType, String> map = dataNode.getUserData(GradleProjectResolver.GRADLE_OUTPUTS);
|
||||
if(map == null) {
|
||||
map = ContainerUtil.newHashMap();
|
||||
dataNode.putUserData(GradleProjectResolver.GRADLE_OUTPUTS, map);
|
||||
}
|
||||
map.put(sourceType, gradleOutputPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+6
-4
@@ -89,7 +89,7 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
Key.create("resolvedSourceSets");
|
||||
public static final Key<Map<String/* output path */, Pair<String /* module id*/, ExternalSystemSourceType>>> MODULES_OUTPUTS =
|
||||
Key.create("moduleOutputsMap");
|
||||
public static final Key<Map<ExternalSystemSourceType, String /* output path*/>> GRADLE_OUTPUTS = Key.create("gradleOutputs");
|
||||
public static final Key<MultiMap<ExternalSystemSourceType, String /* output path*/>> GRADLE_OUTPUTS = Key.create("gradleOutputs");
|
||||
public static final Key<Map<String/* artifact path */, String /* module id*/>> CONFIGURATION_ARTIFACTS =
|
||||
Key.create("gradleArtifactsMap");
|
||||
|
||||
@@ -526,10 +526,11 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
final ModuleData moduleData = pair.first.getData();
|
||||
if (targetModuleOutputPaths == null) {
|
||||
final Set<String> compileSet = ContainerUtil.newHashSet();
|
||||
Map<ExternalSystemSourceType, String> gradleOutputs = pair.first.getUserData(GRADLE_OUTPUTS);
|
||||
MultiMap<ExternalSystemSourceType, String> gradleOutputs = pair.first.getUserData(GRADLE_OUTPUTS);
|
||||
if(gradleOutputs != null) {
|
||||
ContainerUtil.addAllNotNull(compileSet,
|
||||
gradleOutputs.get(ExternalSystemSourceType.SOURCE),
|
||||
gradleOutputs.get(ExternalSystemSourceType.SOURCE));
|
||||
ContainerUtil.addAllNotNull(compileSet,
|
||||
gradleOutputs.get(ExternalSystemSourceType.RESOURCE));
|
||||
}
|
||||
if (!compileSet.isEmpty() && ContainerUtil.intersects(libraryPaths, compileSet)) {
|
||||
@@ -539,7 +540,8 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
final Set<String> testSet = ContainerUtil.newHashSet();
|
||||
if(gradleOutputs != null) {
|
||||
ContainerUtil.addAllNotNull(testSet,
|
||||
gradleOutputs.get(ExternalSystemSourceType.TEST),
|
||||
gradleOutputs.get(ExternalSystemSourceType.TEST));
|
||||
ContainerUtil.addAllNotNull(testSet,
|
||||
gradleOutputs.get(ExternalSystemSourceType.TEST_RESOURCE));
|
||||
}
|
||||
if (!testSet.isEmpty() && ContainerUtil.intersects(libraryPaths, testSet)) {
|
||||
|
||||
Reference in New Issue
Block a user