Search in sources :

Example 11 with DependencyScope

use of com.intellij.openapi.roots.DependencyScope in project intellij-community by JetBrains.

the class AddLibraryToDependenciesFix method invoke.

@Override
public void invoke(@NotNull Project project, @Nullable Editor editor, PsiFile file) {
    DependencyScope scope = suggestScopeByLocation(myCurrentModule, myReference.getElement());
    JavaProjectModelModificationService.getInstance(project).addDependency(myCurrentModule, myLibrary, scope);
    if (myQualifiedClassName != null && editor != null) {
        importClass(myCurrentModule, editor, myReference, myQualifiedClassName);
    }
}
Also used : DependencyScope(com.intellij.openapi.roots.DependencyScope)

Example 12 with DependencyScope

use of com.intellij.openapi.roots.DependencyScope in project intellij-community by JetBrains.

the class ManifestImporter method getClasspath.

@NotNull
public String getClasspath(@NotNull MavenProject mavenProject, @Nullable Element manifestConfiguration) {
    StringBuilder classpath = new StringBuilder();
    String classpathPrefix = getClasspathPrefix(manifestConfiguration);
    for (MavenArtifact mavenArtifact : mavenProject.getDependencies()) {
        final DependencyScope scope = MavenModuleImporter.selectScope(mavenArtifact.getScope());
        if (scope.isForProductionCompile() || scope.isForProductionRuntime()) {
            if (classpath.length() > 0) {
                classpath.append(" ");
            }
            classpath.append(classpathPrefix);
            String artifactFileName = mavenArtifact.getArtifactId() + "-" + mavenArtifact.getVersion() + "." + mavenArtifact.getExtension();
            classpath.append(doGetClasspathItem(mavenProject, mavenArtifact, artifactFileName));
        }
    }
    return classpath.toString();
}
Also used : DependencyScope(com.intellij.openapi.roots.DependencyScope) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with DependencyScope

use of com.intellij.openapi.roots.DependencyScope in project android by JetBrains.

the class DependenciesModuleSetupStep method updateLibraryDependency.

public void updateLibraryDependency(@NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull LibraryDependency dependency, @NotNull AndroidProject androidProject) {
    String name = dependency.getName();
    DependencyScope scope = dependency.getScope();
    myDependenciesSetup.setUpLibraryDependency(module, modelsProvider, name, scope, dependency.getArtifactPath(), dependency.getPaths(BINARY), dependency.getPaths(DOCUMENTATION));
    File buildFolder = androidProject.getBuildFolder();
    // Exclude jar files that are in "jars" folder in "build" folder.
    // see https://code.google.com/p/android/issues/detail?id=123788
    ContentEntry[] contentEntries = modelsProvider.getModifiableRootModel(module).getContentEntries();
    if (contentEntries.length > 0) {
        for (File binaryPath : dependency.getPaths(BINARY)) {
            File parent = binaryPath.getParentFile();
            if (parent != null && FD_JARS.equals(parent.getName()) && isAncestor(buildFolder, parent, true)) {
                ContentEntry parentContentEntry = findParentContentEntry(parent, contentEntries);
                if (parentContentEntry != null) {
                    parentContentEntry.addExcludeFolder(pathToIdeaUrl(parent));
                }
            }
        }
    }
}
Also used : DependencyScope(com.intellij.openapi.roots.DependencyScope) FilePaths.findParentContentEntry(com.android.tools.idea.gradle.util.FilePaths.findParentContentEntry) ContentEntry(com.intellij.openapi.roots.ContentEntry) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Aggregations

DependencyScope (com.intellij.openapi.roots.DependencyScope)13 NotNull (org.jetbrains.annotations.NotNull)4 File (java.io.File)3 ModuleOrderEntry (com.intellij.openapi.roots.ModuleOrderEntry)2 Nullable (org.jetbrains.annotations.Nullable)2 DefaultExternalDependencyId (org.jetbrains.plugins.gradle.DefaultExternalDependencyId)2 ExternalDependencyId (org.jetbrains.plugins.gradle.ExternalDependencyId)2 DependencySetupErrors (com.android.tools.idea.gradle.project.sync.setup.module.common.DependencySetupErrors)1 FilePaths.findParentContentEntry (com.android.tools.idea.gradle.util.FilePaths.findParentContentEntry)1 Result (com.intellij.openapi.application.Result)1 WriteAction (com.intellij.openapi.application.WriteAction)1 DataNode (com.intellij.openapi.externalSystem.model.DataNode)1 ExternalSystemTaskId (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId)1 NotificationData (com.intellij.openapi.externalSystem.service.notification.NotificationData)1 Module (com.intellij.openapi.module.Module)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 Project (com.intellij.openapi.project.Project)1 ContentEntry (com.intellij.openapi.roots.ContentEntry)1 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)1 OrderEntry (com.intellij.openapi.roots.OrderEntry)1