Search in sources :

Example 51 with Artifact

use of com.intellij.packaging.artifacts.Artifact in project android by JetBrains.

the class AndroidBuildTargetScopeProvider method isProGuardUsed.

private static boolean isProGuardUsed(@NotNull Project project, @NotNull CompileScope scope) {
    for (Module module : scope.getAffectedModules()) {
        final AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet != null && facet.getProperties().RUN_PROGUARD) {
            return true;
        }
    }
    final String proguardCfgPathsStr = scope.getUserData(AndroidCompileUtil.PROGUARD_CFG_PATHS_KEY);
    if (proguardCfgPathsStr != null && proguardCfgPathsStr.length() > 0) {
        return true;
    }
    final Set<Artifact> artifacts = ArtifactCompileScope.getArtifactsToBuild(project, scope, false);
    for (Artifact artifact : artifacts) {
        if (artifact.getArtifactType() instanceof AndroidApplicationArtifactType) {
            final ArtifactProperties<?> properties = artifact.getProperties(AndroidArtifactPropertiesProvider.getInstance());
            if (properties instanceof AndroidApplicationArtifactProperties) {
                final AndroidApplicationArtifactProperties p = (AndroidApplicationArtifactProperties) properties;
                if (p.isRunProGuard()) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : AndroidApplicationArtifactProperties(org.jetbrains.android.compiler.artifact.AndroidApplicationArtifactProperties) Module(com.intellij.openapi.module.Module) AndroidApplicationArtifactType(org.jetbrains.android.compiler.artifact.AndroidApplicationArtifactType) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 52 with Artifact

use of com.intellij.packaging.artifacts.Artifact in project android by JetBrains.

the class NonGradleApkProvider method addApk.

private void addApk(@NotNull List<ApkInfo> apkList, @NotNull String packageName, @NotNull AndroidFacet facet) throws ApkProvisionException {
    final Module module = facet.getModule();
    String localPath;
    if (myArtifactName != null && myArtifactName.length() > 0) {
        final Artifact artifact = ArtifactManager.getInstance(facet.getModule().getProject()).findArtifact(myArtifactName);
        if (artifact == null) {
            throw new ApkProvisionException("ERROR: cannot find artifact \"" + myArtifactName + '"');
        }
        if (!AndroidArtifactUtil.isRelatedArtifact(artifact, facet.getModule())) {
            throw new ApkProvisionException("ERROR: artifact \"" + myArtifactName + "\" doesn't contain packaged module \"" + facet.getModule().getName() + '"');
        }
        final String artifactOutPath = artifact.getOutputFilePath();
        if (artifactOutPath == null || artifactOutPath.length() == 0) {
            throw new ApkProvisionException("ERROR: output path is not specified for artifact \"" + myArtifactName + '"');
        }
        localPath = FileUtil.toSystemDependentName(artifactOutPath);
    } else {
        localPath = AndroidRootUtil.getApkPath(facet);
    }
    if (localPath == null) {
        throw new ApkProvisionException("ERROR: APK path is not specified for module \"" + module.getName() + '"');
    }
    apkList.add(new ApkInfo(new File(localPath), packageName));
}
Also used : Module(com.intellij.openapi.module.Module) File(java.io.File) Artifact(com.intellij.packaging.artifacts.Artifact)

Aggregations

Artifact (com.intellij.packaging.artifacts.Artifact)52 ArrayList (java.util.ArrayList)13 Project (com.intellij.openapi.project.Project)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 Module (com.intellij.openapi.module.Module)7 NotNull (org.jetbrains.annotations.NotNull)6 ArtifactManager (com.intellij.packaging.artifacts.ArtifactManager)5 File (java.io.File)5 PackagingElement (com.intellij.packaging.elements.PackagingElement)4 ArtifactCompileScope (com.intellij.packaging.impl.compiler.ArtifactCompileScope)4 ArtifactPackagingElement (com.intellij.packaging.impl.elements.ArtifactPackagingElement)4 Nullable (org.jetbrains.annotations.Nullable)4 ArtifactType (com.intellij.packaging.artifacts.ArtifactType)3 PackagingElementPath (com.intellij.packaging.impl.artifacts.PackagingElementPath)3 ReadAction (com.intellij.openapi.application.ReadAction)2 Result (com.intellij.openapi.application.Result)2 Pair (com.intellij.openapi.util.Pair)2 ModifiableArtifactModel (com.intellij.packaging.artifacts.ModifiableArtifactModel)2 CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)2 PackagingElementFactory (com.intellij.packaging.elements.PackagingElementFactory)2