use of com.intellij.openapi.roots.DependencyScope in project intellij-community by JetBrains.
the class BaseGradleProjectResolverExtension method populateModuleDependencies.
@Override
public void populateModuleDependencies(@NotNull IdeaModule gradleModule, @NotNull DataNode<ModuleData> ideModule, @NotNull final DataNode<ProjectData> ideProject) {
ExternalProject externalProject = resolverCtx.getExtraProject(gradleModule, ExternalProject.class);
if (externalProject != null) {
final Map<String, Pair<DataNode<GradleSourceSetData>, ExternalSourceSet>> sourceSetMap = ideProject.getUserData(GradleProjectResolver.RESOLVED_SOURCE_SETS);
final Map<String, String> artifactsMap = ideProject.getUserData(CONFIGURATION_ARTIFACTS);
assert artifactsMap != null;
if (resolverCtx.isResolveModulePerSourceSet()) {
assert sourceSetMap != null;
processSourceSets(resolverCtx, gradleModule, externalProject, ideModule, new SourceSetsProcessor() {
@Override
public void process(@NotNull DataNode<? extends ModuleData> dataNode, @NotNull ExternalSourceSet sourceSet) {
buildDependencies(resolverCtx, sourceSetMap, artifactsMap, dataNode, sourceSet.getDependencies(), ideProject);
}
});
return;
}
}
final List<? extends IdeaDependency> dependencies = gradleModule.getDependencies().getAll();
if (dependencies == null)
return;
List<String> orphanModules = ContainerUtil.newArrayList();
for (IdeaDependency dependency : dependencies) {
if (dependency == null) {
continue;
}
DependencyScope scope = parseScope(dependency.getScope());
if (dependency instanceof IdeaModuleDependency) {
ModuleDependencyData d = buildDependency(resolverCtx, ideModule, (IdeaModuleDependency) dependency, ideProject);
d.setExported(dependency.getExported());
if (scope != null) {
d.setScope(scope);
}
ideModule.createChild(ProjectKeys.MODULE_DEPENDENCY, d);
ModuleData targetModule = d.getTarget();
if (targetModule.getId().isEmpty() && targetModule.getLinkedExternalProjectPath().isEmpty()) {
orphanModules.add(targetModule.getExternalName());
}
} else if (dependency instanceof IdeaSingleEntryLibraryDependency) {
LibraryDependencyData d = buildDependency(gradleModule, ideModule, (IdeaSingleEntryLibraryDependency) dependency, ideProject);
d.setExported(dependency.getExported());
if (scope != null) {
d.setScope(scope);
}
ideModule.createChild(ProjectKeys.LIBRARY_DEPENDENCY, d);
}
}
if (!orphanModules.isEmpty()) {
ExternalSystemTaskId taskId = resolverCtx.getExternalSystemTaskId();
Project project = taskId.findProject();
if (project != null) {
String msg = "Can't find the following module" + (orphanModules.size() > 1 ? "s" : "") + ": " + StringUtil.join(orphanModules, ", ") + "\nIt can be caused by composite build configuration inside your *.gradle scripts with Gradle version older than 3.3." + "\nTry Gradle 3.3 or better or enable 'Create separate module per source set' option";
NotificationData notification = new NotificationData("Gradle project structure problems", msg, NotificationCategory.WARNING, NotificationSource.PROJECT_SYNC);
ExternalSystemNotificationManager.getInstance(project).showNotification(taskId.getProjectSystemId(), notification);
}
}
}
use of com.intellij.openapi.roots.DependencyScope in project intellij-community by JetBrains.
the class GradleProjectResolverUtil method getModuleId.
@NotNull
public static String getModuleId(@NotNull ExternalProjectDependency projectDependency) {
DependencyScope dependencyScope = getDependencyScope(projectDependency.getScope());
String projectPath = projectDependency.getProjectPath();
String moduleId = StringUtil.isEmpty(projectPath) || ":".equals(projectPath) ? projectDependency.getName() : projectPath;
if (Dependency.DEFAULT_CONFIGURATION.equals(projectDependency.getConfigurationName())) {
moduleId += dependencyScope == DependencyScope.TEST ? ":test" : ":main";
} else {
moduleId += (':' + projectDependency.getConfigurationName());
}
return moduleId;
}
use of com.intellij.openapi.roots.DependencyScope in project android by JetBrains.
the class DependenciesModuleSetupStep method updateDependency.
private void updateDependency(@NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull JarLibraryDependency dependency) {
DependencyScope scope = parseScope(dependency.getScope());
File binaryPath = dependency.getBinaryPath();
if (binaryPath == null) {
DependencySetupErrors setupErrors = DependencySetupErrors.getInstance(module.getProject());
setupErrors.addMissingBinaryPath(module.getName());
return;
}
// Gradle API doesn't provide library name at the moment.
String name = binaryPath.isFile() ? getNameWithoutExtension(binaryPath) : sanitizeFileName(binaryPath.getPath());
myDependenciesSetup.setUpLibraryDependency(module, modelsProvider, name, scope, binaryPath, dependency.getSourcePath(), dependency.getJavadocPath());
}
use of com.intellij.openapi.roots.DependencyScope in project intellij-plugins by JetBrains.
the class FlexModuleConverter method convertDependencyType.
private static void convertDependencyType(Element orderEntry, ModifiableDependencyType dependencyType) {
DependencyScope scope = DependencyScope.readExternal(orderEntry);
boolean isExported = orderEntry.getAttribute(ModuleLibraryOrderEntryImpl.EXPORTED_ATTR) != null;
dependencyType.setLinkageType(FlexUtils.convertLinkageType(scope, isExported));
}
use of com.intellij.openapi.roots.DependencyScope in project intellij-community by JetBrains.
the class AddExternalLibraryToDependenciesQuickFix method invoke.
@Override
public void invoke(@NotNull Project project, final Editor editor, PsiFile file) throws IncorrectOperationException {
DependencyScope scope = suggestScopeByLocation(myCurrentModule, myReference.getElement());
JavaProjectModelModificationService.getInstance(project).addDependency(myCurrentModule, myLibraryDescriptor, scope).done(aVoid -> new WriteAction() {
protected void run(@NotNull final Result result) {
try {
importClass(myCurrentModule, editor, myReference, myQualifiedClassName);
} catch (IndexNotReadyException e) {
LOG.info(e);
}
}
}.execute());
}
Aggregations