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