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);
}
}
}
}
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;
}
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());
}
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;
}
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);
}
Aggregations