Search in sources :

Example 1 with ARTIFACT_TYPE

use of com.android.build.gradle.internal.publishing.AndroidArtifacts.ARTIFACT_TYPE in project atlas by alibaba.

the class AtlasDependencyGraph method computeArtifactCollection.

public static ArtifactCollection computeArtifactCollection(VariantScope variantScope, @NonNull AtlasAndroidArtifacts.ConsumedConfigType configType, @NonNull AndroidArtifacts.ArtifactScope scope, @NonNull AtlasAndroidArtifacts.AtlasArtifactType artifactType) {
    Configuration configuration;
    switch(configType) {
        case COMPILE_CLASSPATH:
            configuration = variantScope.getVariantData().getVariantDependency().getCompileClasspath();
            break;
        case RUNTIME_CLASSPATH:
            configuration = variantScope.getVariantData().getVariantDependency().getRuntimeClasspath();
            break;
        case BUNDLECOMPILE_CLASSPATH:
            configuration = variantScope.getGlobalScope().getProject().getConfigurations().maybeCreate(AtlasPlugin.BUNDLE_COMPILE);
            break;
        case ANNOTATION_PROCESSOR:
            configuration = variantScope.getVariantData().getVariantDependency().getAnnotationProcessorConfiguration();
            break;
        case METADATA_VALUES:
            configuration = variantScope.getVariantData().getVariantDependency().getMetadataValuesConfiguration();
            break;
        default:
            throw new RuntimeException("unknown ConfigType value");
    }
    Action<AttributeContainer> attributes = container -> container.attribute(ARTIFACT_TYPE, artifactType.getType());
    Spec<ComponentIdentifier> filter = getComponentFilter(scope);
    boolean lenientMode = Boolean.TRUE.equals(variantScope.getGlobalScope().getProjectOptions().get(BooleanOption.IDE_BUILD_MODEL_ONLY));
    ArtifactCollection artifacts = configuration.getIncoming().artifactView(config -> {
        config.attributes(attributes);
        if (filter != null) {
            config.componentFilter(filter);
        }
        // TODO somehow read the unresolved dependencies?
        config.lenient(lenientMode);
    }).getArtifacts();
    if (configType == AtlasAndroidArtifacts.ConsumedConfigType.RUNTIME_CLASSPATH && variantScope.getVariantConfiguration().getType() == VariantType.FEATURE && artifactType != AtlasAndroidArtifacts.AtlasArtifactType.FEATURE_TRANSITIVE_DEPS) {
        artifacts = new FilteredArtifactCollection(variantScope.getGlobalScope().getProject(), artifacts, computeArtifactCollection(variantScope, AtlasAndroidArtifacts.ConsumedConfigType.RUNTIME_CLASSPATH, scope, AtlasAndroidArtifacts.AtlasArtifactType.FEATURE_TRANSITIVE_DEPS).getArtifactFiles());
    }
    return artifacts;
}
Also used : ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) AtlasPlugin(com.taobao.android.builder.AtlasPlugin) AtlasAndroidArtifacts(com.android.build.gradle.internal.publishing.AtlasAndroidArtifacts) CreatingCache(com.android.ide.common.caching.CreatingCache) Matcher(java.util.regex.Matcher) FileUtils(com.android.utils.FileUtils) ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) com.google.common.collect(com.google.common.collect) MavenCoordinatesImpl(com.android.builder.dependency.MavenCoordinatesImpl) Artifact(org.gradle.api.component.Artifact) GraphItem(com.android.builder.model.level2.GraphItem) Project(org.gradle.api.Project) Nullable(com.android.annotations.Nullable) AndroidArtifacts(com.android.build.gradle.internal.publishing.AndroidArtifacts) BooleanOption(com.android.build.gradle.options.BooleanOption) ComponentArtifactIdentifier(org.gradle.api.artifacts.component.ComponentArtifactIdentifier) ArtifactCollection(org.gradle.api.artifacts.ArtifactCollection) FilteredArtifactCollection(com.android.build.gradle.internal.dependency.FilteredArtifactCollection) Spec(org.gradle.api.specs.Spec) NonNull(com.android.annotations.NonNull) VariantType(com.android.builder.core.VariantType) ARTIFACT_TYPE(com.android.build.gradle.internal.publishing.AndroidArtifacts.ARTIFACT_TYPE) com.android.build.gradle.internal.ide.level2(com.android.build.gradle.internal.ide.level2) Pattern(java.util.regex.Pattern) ResolvedArtifactResult(org.gradle.api.artifacts.result.ResolvedArtifactResult) EMPTY_DEPENDENCY_GRAPH(com.android.build.gradle.internal.ide.ModelBuilder.EMPTY_DEPENDENCY_GRAPH) JvmLibrary(org.gradle.jvm.JvmLibrary) java.util(java.util) SdkConstants(com.android.SdkConstants) OpaqueComponentArtifactIdentifier(org.gradle.internal.component.local.model.OpaqueComponentArtifactIdentifier) VariantAttr(com.android.build.gradle.internal.dependency.VariantAttr) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) ConfigurationDependencyGraphs(com.android.build.gradle.internal.dependency.ConfigurationDependencyGraphs) VariantScope(com.android.build.gradle.internal.scope.VariantScope) EMPTY_DEPENDENCIES_IMPL(com.android.build.gradle.internal.ide.ModelBuilder.EMPTY_DEPENDENCIES_IMPL) Configuration(org.gradle.api.artifacts.Configuration) ImmutableCollectors(com.android.utils.ImmutableCollectors) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) AttributeContainer(org.gradle.api.attributes.AttributeContainer) com.android.builder.model(com.android.builder.model) ArtifactResolutionQuery(org.gradle.api.artifacts.query.ArtifactResolutionQuery) SourcesArtifact(org.gradle.language.base.artifact.SourcesArtifact) Action(org.gradle.api.Action) Library(com.android.builder.model.level2.Library) File(java.io.File) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) Consumer(java.util.function.Consumer) ArtifactCollectionWithExtraArtifact(com.android.build.gradle.internal.dependency.ArtifactCollectionWithExtraArtifact) JavaLibraryImpl(com.android.build.gradle.internal.ide.level2.JavaLibraryImpl) Preconditions(com.google.common.base.Preconditions) DependencyGraphs(com.android.builder.model.level2.DependencyGraphs) Configuration(org.gradle.api.artifacts.Configuration) ArtifactCollection(org.gradle.api.artifacts.ArtifactCollection) FilteredArtifactCollection(com.android.build.gradle.internal.dependency.FilteredArtifactCollection) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) AttributeContainer(org.gradle.api.attributes.AttributeContainer) FilteredArtifactCollection(com.android.build.gradle.internal.dependency.FilteredArtifactCollection)

Aggregations

SdkConstants (com.android.SdkConstants)1 NonNull (com.android.annotations.NonNull)1 Nullable (com.android.annotations.Nullable)1 ArtifactCollectionWithExtraArtifact (com.android.build.gradle.internal.dependency.ArtifactCollectionWithExtraArtifact)1 ConfigurationDependencyGraphs (com.android.build.gradle.internal.dependency.ConfigurationDependencyGraphs)1 FilteredArtifactCollection (com.android.build.gradle.internal.dependency.FilteredArtifactCollection)1 VariantAttr (com.android.build.gradle.internal.dependency.VariantAttr)1 EMPTY_DEPENDENCIES_IMPL (com.android.build.gradle.internal.ide.ModelBuilder.EMPTY_DEPENDENCIES_IMPL)1 EMPTY_DEPENDENCY_GRAPH (com.android.build.gradle.internal.ide.ModelBuilder.EMPTY_DEPENDENCY_GRAPH)1 com.android.build.gradle.internal.ide.level2 (com.android.build.gradle.internal.ide.level2)1 JavaLibraryImpl (com.android.build.gradle.internal.ide.level2.JavaLibraryImpl)1 AndroidArtifacts (com.android.build.gradle.internal.publishing.AndroidArtifacts)1 ARTIFACT_TYPE (com.android.build.gradle.internal.publishing.AndroidArtifacts.ARTIFACT_TYPE)1 AtlasAndroidArtifacts (com.android.build.gradle.internal.publishing.AtlasAndroidArtifacts)1 VariantScope (com.android.build.gradle.internal.scope.VariantScope)1 BooleanOption (com.android.build.gradle.options.BooleanOption)1 VariantType (com.android.builder.core.VariantType)1 MavenCoordinatesImpl (com.android.builder.dependency.MavenCoordinatesImpl)1 com.android.builder.model (com.android.builder.model)1 DependencyGraphs (com.android.builder.model.level2.DependencyGraphs)1