Search in sources :

Example 1 with AndroidApplicationArtifactType

use of org.jetbrains.jps.android.model.AndroidApplicationArtifactType in project android by JetBrains.

the class AndroidArtifactBuildTaskProvider method createArtifactBuildTasks.

@NotNull
@Override
public List<? extends BuildTask> createArtifactBuildTasks(@NotNull JpsArtifact artifact, @NotNull ArtifactBuildPhase buildPhase) {
    if (buildPhase != ArtifactBuildPhase.FINISHING_BUILD) {
        return Collections.emptyList();
    }
    if (!(artifact.getArtifactType() instanceof AndroidApplicationArtifactType)) {
        return Collections.emptyList();
    }
    final JpsElement props = artifact.getProperties();
    if (!(props instanceof JpsAndroidApplicationArtifactProperties)) {
        return Collections.emptyList();
    }
    final JpsAndroidApplicationArtifactProperties androidProps = (JpsAndroidApplicationArtifactProperties) props;
    if (!(artifact.getArtifactType() instanceof AndroidApplicationArtifactType)) {
        return Collections.emptyList();
    }
    final AndroidArtifactSigningMode signingMode = androidProps.getSigningMode();
    if (signingMode != AndroidArtifactSigningMode.RELEASE_SIGNED && signingMode != AndroidArtifactSigningMode.DEBUG_WITH_CUSTOM_CERTIFICATE) {
        return Collections.emptyList();
    }
    final JpsAndroidModuleExtension extension = AndroidJpsUtil.getPackagedFacet(artifact);
    return extension != null ? Collections.singletonList(new MyTask(artifact, extension, androidProps)) : Collections.<BuildTask>emptyList();
}
Also used : JpsElement(org.jetbrains.jps.model.JpsElement) JpsAndroidModuleExtension(org.jetbrains.jps.android.model.JpsAndroidModuleExtension) JpsAndroidApplicationArtifactProperties(org.jetbrains.jps.android.model.JpsAndroidApplicationArtifactProperties) AndroidApplicationArtifactType(org.jetbrains.jps.android.model.AndroidApplicationArtifactType) AndroidArtifactSigningMode(org.jetbrains.android.compiler.artifact.AndroidArtifactSigningMode) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with AndroidApplicationArtifactType

use of org.jetbrains.jps.android.model.AndroidApplicationArtifactType in project android by JetBrains.

the class AndroidSourceGeneratingBuilder method checkUnambiguousAndRecursiveArtifacts.

private static boolean checkUnambiguousAndRecursiveArtifacts(CompileContext context, List<JpsArtifact> artifacts) {
    boolean success = true;
    for (JpsArtifact artifact : artifacts) {
        if (artifact.getArtifactType() instanceof AndroidApplicationArtifactType) {
            final List<JpsAndroidModuleExtension> facets = AndroidJpsUtil.getAllPackagedFacets(artifact);
            if (facets.size() > 1) {
                context.processMessage(new CompilerMessage(ANDROID_VALIDATOR, BuildMessage.Kind.ERROR, "Cannot build artifact '" + artifact.getName() + "' because it contains more than one Android package"));
                success = false;
                continue;
            }
            final String artifactOutputPath = artifact.getOutputFilePath();
            if (artifactOutputPath != null && facets.size() > 0) {
                final JpsAndroidModuleExtension facet = facets.get(0);
                final String apkPath = AndroidFinalPackageElementBuilder.getApkPath(facet);
                if (FileUtil.pathsEqual(apkPath, artifactOutputPath)) {
                    context.processMessage(new CompilerMessage(ANDROID_VALIDATOR, BuildMessage.Kind.ERROR, "Incorrect output path for artifact '" + artifact.getName() + "': " + FileUtil.toSystemDependentName(apkPath)));
                    success = false;
                }
            }
        }
    }
    return success;
}
Also used : CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) JpsAndroidModuleExtension(org.jetbrains.jps.android.model.JpsAndroidModuleExtension) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) AndroidApplicationArtifactType(org.jetbrains.jps.android.model.AndroidApplicationArtifactType)

Aggregations

AndroidApplicationArtifactType (org.jetbrains.jps.android.model.AndroidApplicationArtifactType)2 JpsAndroidModuleExtension (org.jetbrains.jps.android.model.JpsAndroidModuleExtension)2 AndroidArtifactSigningMode (org.jetbrains.android.compiler.artifact.AndroidArtifactSigningMode)1 NotNull (org.jetbrains.annotations.NotNull)1 JpsAndroidApplicationArtifactProperties (org.jetbrains.jps.android.model.JpsAndroidApplicationArtifactProperties)1 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)1 JpsElement (org.jetbrains.jps.model.JpsElement)1 JpsArtifact (org.jetbrains.jps.model.artifact.JpsArtifact)1