Search in sources :

Example 11 with MavenArtifact

use of org.jetbrains.idea.maven.model.MavenArtifact in project android by JetBrains.

the class AndroidFacetImporterBase method resolve.

@Override
public void resolve(final Project project, MavenProject mavenProject, NativeMavenProjectHolder nativeMavenProject, MavenEmbedderWrapper embedder, ResolveContext context) throws MavenProcessCanceledException {
    final AndroidExternalApklibDependenciesManager adm = AndroidExternalApklibDependenciesManager.getInstance(project);
    for (MavenArtifact depArtifact : mavenProject.getDependencies()) {
        final MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(project);
        if (AndroidMavenUtil.APKLIB_DEPENDENCY_AND_PACKAGING_TYPE.equals(depArtifact.getType()) && mavenProjectsManager.findProject(depArtifact) == null && MavenConstants.SCOPE_COMPILE.equals(depArtifact.getScope())) {
            Set<MavenId> resolvedArtifacts = context.getUserData(RESOLVED_APKLIB_ARTIFACTS_KEY);
            if (resolvedArtifacts == null) {
                resolvedArtifacts = new HashSet<MavenId>();
                context.putUserData(RESOLVED_APKLIB_ARTIFACTS_KEY, resolvedArtifacts);
            }
            if (resolvedArtifacts.add(depArtifact.getMavenId())) {
                doResolveApklibArtifact(project, depArtifact, embedder, mavenProjectsManager, mavenProject.getName(), adm, context);
            }
        }
    }
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact)

Example 12 with MavenArtifact

use of org.jetbrains.idea.maven.model.MavenArtifact in project android by JetBrains.

the class AndroidMavenProviderImpl method getMavenDependencyArtifactFiles.

@Override
@NotNull
public List<File> getMavenDependencyArtifactFiles(@NotNull Module module) {
    MavenProject mavenProject = MavenProjectsManager.getInstance(module.getProject()).findProject(module);
    List<File> result = new ArrayList<File>();
    if (mavenProject != null) {
        for (MavenArtifact depArtifact : mavenProject.getDependencies()) {
            if (AndroidMavenUtil.APKSOURCES_DEPENDENCY_TYPE.equals(depArtifact.getType())) {
                result.add(MavenArtifactUtil.getArtifactFile(mavenProject.getLocalRepository(), depArtifact.getMavenId()));
            }
        }
    }
    return result;
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject) ArrayList(java.util.ArrayList) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with MavenArtifact

use of org.jetbrains.idea.maven.model.MavenArtifact in project android by JetBrains.

the class AndroidMavenUtil method isMavenAarDependency.

public static boolean isMavenAarDependency(@NotNull Module module, @NotNull OrderEntry entry) {
    if (ApplicationManager.getApplication().isUnitTestMode() && entry.getPresentableName().equals("maven_aar_dependency")) {
        return true;
    }
    if (!(entry instanceof LibraryOrderEntry) || !isMavenizedModule(module)) {
        return false;
    }
    final Library library = ((LibraryOrderEntry) entry).getLibrary();
    if (library == null) {
        return false;
    }
    final MavenProject mavenProject = MavenProjectsManager.getInstance(module.getProject()).findProject(module);
    if (mavenProject == null) {
        return false;
    }
    final MavenArtifact artifact = MavenRootModelAdapter.findArtifact(mavenProject, library);
    return artifact != null && AAR_DEPENDENCY_AND_PACKAGING_TYPE.equals(artifact.getType());
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Library(com.intellij.openapi.roots.libraries.Library) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact)

Example 14 with MavenArtifact

use of org.jetbrains.idea.maven.model.MavenArtifact in project android by JetBrains.

the class AndroidMavenUtil method computePathForGenExternalApklibsDir.

@Nullable
public static String computePathForGenExternalApklibsDir(@NotNull MavenId mavenId, @NotNull MavenProject project, @NotNull Collection<MavenProject> allProjects) {
    String path = null;
    boolean resultUnderApp = false;
    for (MavenProject p : allProjects) {
        List<MavenArtifact> dependencies = p.findDependencies(mavenId);
        if (dependencies.size() == 0) {
            dependencies = p.findDependencies(mavenId.getGroupId(), mavenId.getArtifactId());
        }
        if (dependencies.size() > 0 && containsCompileDependency(dependencies)) {
            final VirtualFile projectDir = p.getDirectoryFile();
            final boolean app = APK_PACKAGING_TYPE.equals(p.getPackaging());
            if (path == null || !resultUnderApp && app) {
                path = projectDir.getPath() + '/' + GEN_EXTERNAL_APKLIBS_DIRNAME;
                resultUnderApp = app;
            }
        }
    }
    if (path == null) {
        path = getGenExternalApklibDirInProject(project);
    }
    return path;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with MavenArtifact

use of org.jetbrains.idea.maven.model.MavenArtifact in project intellij-community by JetBrains.

the class MavenArtifactIndex method build.

public static MavenArtifactIndex build(@NotNull List<MavenArtifact> dependencies) {
    if (dependencies.isEmpty())
        return EMPTY_INDEX;
    Map<String, Map<String, List<MavenArtifact>>> map = new HashMap<>();
    for (MavenArtifact dep : dependencies) {
        String groupId = dep.getGroupId();
        if (groupId == null)
            continue;
        String artifactId = dep.getArtifactId();
        if (artifactId == null)
            continue;
        Map<String, List<MavenArtifact>> groupMap = map.get(groupId);
        if (groupMap == null) {
            groupMap = new HashMap<>();
            map.put(groupId, groupMap);
        }
        List<MavenArtifact> artifactList = groupMap.get(artifactId);
        if (artifactList == null) {
            artifactList = new SmartList<>();
            groupMap.put(artifactId, artifactList);
        }
        artifactList.add(dep);
    }
    return new MavenArtifactIndex(map);
}
Also used : HashMap(java.util.HashMap) List(java.util.List) SmartList(com.intellij.util.SmartList) Map(java.util.Map) HashMap(java.util.HashMap) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact)

Aggregations

MavenArtifact (org.jetbrains.idea.maven.model.MavenArtifact)21 File (java.io.File)5 NotNull (org.jetbrains.annotations.NotNull)4 MavenId (org.jetbrains.idea.maven.model.MavenId)4 MavenProject (org.jetbrains.idea.maven.project.MavenProject)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 Library (com.intellij.openapi.roots.libraries.Library)2 SmartList (com.intellij.util.SmartList)2 THashSet (gnu.trove.THashSet)2 List (java.util.List)2 Map (java.util.Map)2 Attrs (aQute.bnd.header.Attrs)1 Parameters (aQute.bnd.header.Parameters)1 Analyzer (aQute.bnd.osgi.Analyzer)1 AccessToken (com.intellij.openapi.application.AccessToken)1 Module (com.intellij.openapi.module.Module)1 DumbProgressIndicator (com.intellij.openapi.progress.DumbProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 CompilerModuleExtension (com.intellij.openapi.roots.CompilerModuleExtension)1 ContentEntry (com.intellij.openapi.roots.ContentEntry)1