Search in sources :

Example 1 with ExternalProjectDataCache

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;
}
Also used : ExternalSourceSet(org.jetbrains.plugins.gradle.model.ExternalSourceSet) ExternalProjectDataCache(org.jetbrains.plugins.gradle.service.project.data.ExternalProjectDataCache) ExternalProject(org.jetbrains.plugins.gradle.model.ExternalProject) File(java.io.File)

Aggregations

File (java.io.File)1 ExternalProject (org.jetbrains.plugins.gradle.model.ExternalProject)1 ExternalSourceSet (org.jetbrains.plugins.gradle.model.ExternalSourceSet)1 ExternalProjectDataCache (org.jetbrains.plugins.gradle.service.project.data.ExternalProjectDataCache)1