Search in sources :

Example 11 with Manifest

use of org.jetbrains.android.dom.manifest.Manifest in project android by JetBrains.

the class AndroidCompileUtil method isLibraryWithBadCircularDependency.

// support for lib<->lib and app<->lib circular dependencies
// see IDEA-79737 for details
public static boolean isLibraryWithBadCircularDependency(@NotNull AndroidFacet facet) {
    if (!facet.canBeDependency()) {
        return false;
    }
    final List<AndroidFacet> dependencies = AndroidUtils.getAllAndroidDependencies(facet.getModule(), false);
    final Manifest manifest = facet.getManifest();
    if (manifest == null) {
        return false;
    }
    final String aPackage = manifest.getPackage().getValue();
    if (aPackage == null || aPackage.length() == 0) {
        return false;
    }
    for (AndroidFacet depFacet : dependencies) {
        final List<AndroidFacet> depDependencies = AndroidUtils.getAllAndroidDependencies(depFacet.getModule(), true);
        if (depDependencies.contains(facet) && dependencies.contains(depFacet) && (depFacet.getModule().getName().compareTo(facet.getModule().getName()) < 0 || !depFacet.canBeDependency())) {
            return true;
        }
    }
    return false;
}
Also used : Manifest(org.jetbrains.android.dom.manifest.Manifest) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 12 with Manifest

use of org.jetbrains.android.dom.manifest.Manifest in project android by JetBrains.

the class AndroidCompileUtil method findCircularDependencyOnLibraryWithSamePackage.

@Nullable
public static Module findCircularDependencyOnLibraryWithSamePackage(@NotNull AndroidFacet facet) {
    final Manifest manifest = facet.getManifest();
    final String aPackage = manifest != null ? manifest.getPackage().getValue() : null;
    if (aPackage == null) {
        return null;
    }
    for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(facet.getModule(), true)) {
        final Manifest depManifest = depFacet.getManifest();
        final String depPackage = depManifest != null ? depManifest.getPackage().getValue() : null;
        if (aPackage.equals(depPackage)) {
            final List<AndroidFacet> depDependencies = AndroidUtils.getAllAndroidDependencies(depFacet.getModule(), false);
            if (depDependencies.contains(facet)) {
                // circular dependency on library with the same package
                return depFacet.getModule();
            }
        }
    }
    return null;
}
Also used : Manifest(org.jetbrains.android.dom.manifest.Manifest) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with Manifest

use of org.jetbrains.android.dom.manifest.Manifest in project android by JetBrains.

the class AndroidCompileUtil method excludeAllBuildConfigsFromCompilation.

private static void excludeAllBuildConfigsFromCompilation(AndroidFacet facet, VirtualFile sourceRoot) {
    final Module module = facet.getModule();
    final Project project = module.getProject();
    final Set<String> packages = new HashSet<String>();
    final Manifest manifest = facet.getManifest();
    final String aPackage = manifest != null ? manifest.getPackage().getStringValue() : null;
    if (aPackage != null) {
        packages.add(aPackage);
    }
    packages.addAll(AndroidUtils.getDepLibsPackages(module));
    for (String p : packages) {
        excludeFromCompilation(project, sourceRoot, p);
    }
}
Also used : Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module) Manifest(org.jetbrains.android.dom.manifest.Manifest) HashSet(com.intellij.util.containers.HashSet)

Example 14 with Manifest

use of org.jetbrains.android.dom.manifest.Manifest in project android by JetBrains.

the class MavenDefaultActivityLocator method getQualifiedActivityName.

@NotNull
@Override
public String getQualifiedActivityName(@NotNull IDevice device) throws ActivityLocatorException {
    File manifestCopy = null;
    try {
        Pair<File, String> pair;
        try {
            pair = ApkProviderUtil.getCopyOfCompilerManifestFile(myFacet);
        } catch (IOException e) {
            throw new ActivityLocatorException("Error while obtaining compiler manifest file", e);
        }
        manifestCopy = pair != null ? pair.getFirst() : null;
        VirtualFile manifestVFile = manifestCopy != null ? LocalFileSystem.getInstance().findFileByIoFile(manifestCopy) : null;
        final Manifest manifest = manifestVFile == null ? null : AndroidUtils.loadDomElement(myFacet.getModule(), manifestVFile, Manifest.class);
        if (manifest == null) {
            throw new ActivityLocatorException("Cannot find " + SdkConstants.FN_ANDROID_MANIFEST_XML + " file");
        }
        String defaultLauncherActivityName = DefaultActivityLocator.getDefaultLauncherActivityName(myFacet.getModule().getProject(), manifest);
        if (defaultLauncherActivityName == null) {
            throw new ActivityLocatorException("Could not locate default activity to launch.");
        }
        return defaultLauncherActivityName;
    } finally {
        if (manifestCopy != null) {
            FileUtil.delete(manifestCopy.getParentFile());
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IOException(java.io.IOException) Manifest(org.jetbrains.android.dom.manifest.Manifest) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with Manifest

use of org.jetbrains.android.dom.manifest.Manifest in project android by JetBrains.

the class AndroidProcessChooserDialog method collectAllProcessNames.

@NotNull
private static Set<String> collectAllProcessNames(Project project) {
    final List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
    final Set<String> result = new HashSet<String>();
    for (AndroidFacet facet : facets) {
        final String packageName = AndroidCompileUtil.getAaptManifestPackage(facet);
        if (packageName != null) {
            result.add(packageName.toLowerCase());
        }
        final Manifest manifest = facet.getManifest();
        if (manifest != null) {
            final XmlElement xmlElement = manifest.getXmlElement();
            if (xmlElement != null) {
                collectProcessNames(xmlElement, result);
            }
        }
        final AndroidModel androidModel = facet.getAndroidModel();
        if (androidModel != null) {
            result.addAll(androidModel.getAllApplicationIds());
        }
    }
    return result;
}
Also used : AndroidModel(com.android.tools.idea.model.AndroidModel) XmlElement(com.intellij.psi.xml.XmlElement) Manifest(org.jetbrains.android.dom.manifest.Manifest) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) HashSet(com.intellij.util.containers.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Manifest (org.jetbrains.android.dom.manifest.Manifest)29 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)14 Module (com.intellij.openapi.module.Module)10 Nullable (org.jetbrains.annotations.Nullable)7 XmlElement (com.intellij.psi.xml.XmlElement)6 HashSet (com.intellij.util.containers.HashSet)5 NotNull (org.jetbrains.annotations.NotNull)5 Project (com.intellij.openapi.project.Project)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 File (java.io.File)4 MergedManifest (com.android.tools.idea.model.MergedManifest)3 IOException (java.io.IOException)3 AndroidManifest (com.android.xml.AndroidManifest)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 Pair (com.intellij.openapi.util.Pair)2 PsiFile (com.intellij.psi.PsiFile)2 HashMap (com.intellij.util.containers.HashMap)2 GenericAttributeValue (com.intellij.util.xml.GenericAttributeValue)2 Application (org.jetbrains.android.dom.manifest.Application)2 ManifestElementWithRequiredName (org.jetbrains.android.dom.manifest.ManifestElementWithRequiredName)2