use of org.jetbrains.plugins.gradle.service.project.data.ExternalProjectDataCache in project intellij-community by JetBrains.
the class GradleOrderEnumeratorHandler method addCustomModuleRoots.
@Override
public boolean addCustomModuleRoots(@NotNull OrderRootType type, @NotNull ModuleRootModel rootModel, @NotNull Collection<String> result, boolean includeProduction, boolean includeTests) {
if (!type.equals(OrderRootType.CLASSES))
return false;
if (!ExternalSystemApiUtil.isExternalSystemAwareModule(GradleConstants.SYSTEM_ID, rootModel.getModule()))
return false;
final String gradleProjectPath = rootModel.getModule().getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY);
if (gradleProjectPath == null) {
LOG.error("Root project path of the Gradle project not found for " + rootModel.getModule());
return false;
}
final ExternalProjectDataCache externalProjectDataCache = ExternalProjectDataCache.getInstance(rootModel.getModule().getProject());
assert externalProjectDataCache != null;
final ExternalProject externalRootProject = externalProjectDataCache.getRootExternalProject(GradleConstants.SYSTEM_ID, new File(gradleProjectPath));
if (externalRootProject == null) {
LOG.debug("Root external project was not yep imported for the project path: " + gradleProjectPath);
return false;
}
Map<String, ExternalSourceSet> externalSourceSets = externalProjectDataCache.findExternalProject(externalRootProject, rootModel.getModule());
if (externalSourceSets.isEmpty())
return false;
for (ExternalSourceSet sourceSet : externalSourceSets.values()) {
if (includeTests) {
addOutputModuleRoots(sourceSet.getSources().get(ExternalSystemSourceType.TEST_RESOURCE), result);
}
if (includeProduction) {
addOutputModuleRoots(sourceSet.getSources().get(ExternalSystemSourceType.RESOURCE), result);
}
}
return true;
}
Aggregations