org.gradle.api.attributes.AttributeContainer Java Examples
The following examples show how to use
org.gradle.api.attributes.AttributeContainer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WrappedNativeLibraryPlugin.java From native-samples with Apache License 2.0 | 6 votes |
@Override public Set<? extends UsageContext> getUsages() { Set<UsageContext> result = new HashSet<>(); AttributeContainer linkAttributes = attributesFactory.mutable((AttributeContainerInternal) link.getAttributes().getAttributes()); linkAttributes.attribute(Usage.USAGE_ATTRIBUTE, linkUsage); linkAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED); result.add(new DefaultUsageContext(variantName + "Link", linkAttributes, link.getArtifacts(), link)); AttributeContainer runtimeAttributes = attributesFactory.mutable((AttributeContainerInternal) runtime.getAttributes().getAttributes()); runtimeAttributes.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage); runtimeAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED); result.add(new DefaultUsageContext(variantName + "Runtime", runtimeAttributes, runtime.getArtifacts(), runtime)); return result; }
Example #2
Source File: WrappedNativeLibraryPlugin.java From native-samples with Apache License 2.0 | 6 votes |
@Override public Set<? extends UsageContext> getUsages() { Set<UsageContext> result = new HashSet<>(); AttributeContainer linkAttributes = attributesFactory.mutable((AttributeContainerInternal) link.getAttributes().getAttributes()); linkAttributes.attribute(Usage.USAGE_ATTRIBUTE, linkUsage); linkAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED); result.add(new DefaultUsageContext(variantName + "Link", linkAttributes, link.getArtifacts(), link)); AttributeContainer runtimeAttributes = attributesFactory.mutable((AttributeContainerInternal) runtime.getAttributes().getAttributes()); runtimeAttributes.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage); runtimeAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED); result.add(new DefaultUsageContext(variantName + "Runtime", runtimeAttributes, runtime.getArtifacts(), runtime)); return result; }
Example #3
Source File: WrappedNativeLibraryPlugin.java From native-samples with Apache License 2.0 | 6 votes |
@Override public Set<? extends UsageContext> getUsages() { Set<UsageContext> result = new HashSet<>(); AttributeContainer linkAttributes = attributesFactory.mutable((AttributeContainerInternal) link.getAttributes().getAttributes()); linkAttributes.attribute(Usage.USAGE_ATTRIBUTE, linkUsage); linkAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED); result.add(new DefaultUsageContext(variantName + "Link", linkAttributes, link.getArtifacts(), link)); AttributeContainer runtimeAttributes = attributesFactory.mutable((AttributeContainerInternal) runtime.getAttributes().getAttributes()); runtimeAttributes.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage); runtimeAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED); result.add(new DefaultUsageContext(variantName + "Runtime", runtimeAttributes, runtime.getArtifacts(), runtime)); return result; }
Example #4
Source File: WrappedNativeLibraryPlugin.java From native-samples with Apache License 2.0 | 6 votes |
@Override public Set<? extends UsageContext> getUsages() { Set<UsageContext> result = new HashSet<>(); AttributeContainer linkAttributes = attributesFactory.mutable((AttributeContainerInternal) link.getAttributes().getAttributes()); linkAttributes.attribute(Usage.USAGE_ATTRIBUTE, linkUsage); linkAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED); result.add(new DefaultUsageContext(variantName + "Link", linkAttributes, link.getArtifacts(), link)); AttributeContainer runtimeAttributes = attributesFactory.mutable((AttributeContainerInternal) runtime.getAttributes().getAttributes()); runtimeAttributes.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage); runtimeAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED); result.add(new DefaultUsageContext(variantName + "Runtime", runtimeAttributes, runtime.getArtifacts(), runtime)); return result; }
Example #5
Source File: GenerateHensonNavigatorTask.java From dart with Apache License 2.0 | 6 votes |
@InputFiles @Classpath FileCollection getJarDependencies() { //Thanks to Xavier Durcrohet for this //https://android.googlesource.com/platform/tools/base/+/gradle_3.0.0/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/scope/VariantScopeImpl.java#1037 Action<AttributeContainer> attributes = container -> container.attribute(ARTIFACT_TYPE, AndroidArtifacts.ArtifactType.CLASSES.getType()); boolean lenientMode = false; return variant .getCompileConfiguration() .getIncoming() .artifactView( config -> { config.attributes(attributes); config.lenient(lenientMode); }) .getArtifacts() .getArtifactFiles(); }
Example #6
Source File: CompileTask.java From gradle-modules-plugin with MIT License | 5 votes |
private void enforceJarForCompilation() { Configuration config = project.getConfigurations().getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME); config.attributes(new Action<AttributeContainer>() { @Override public void execute(AttributeContainer attributeContainer) { if(GradleVersion.current().compareTo(GradleVersion.version("5.6")) < 0) { LOGGER.warn("Cannot enforce using JARs for compilation. Please upgrade to Gradle 5.6 or newer."); return; } attributeContainer.attribute( LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.getObjects().named(LibraryElements.class, LibraryElements.JAR)); } }); }
Example #7
Source File: WrappedNativeLibraryPlugin.java From native-samples with Apache License 2.0 | 5 votes |
public DefaultMainPublication(Provider<String> baseName, Usage apiUsage, Configuration api, ImmutableAttributesFactory immutableAttributesFactory, ObjectFactory objectFactory) { this.baseName = baseName; AttributeContainer publicationAttributes = immutableAttributesFactory.mutable(); publicationAttributes.attribute(Usage.USAGE_ATTRIBUTE, apiUsage); publicationAttributes.attribute(ArtifactAttributes.ARTIFACT_FORMAT, ZIP_TYPE); this.mainVariant = new MainLibraryVariant("api", apiUsage, api, publicationAttributes, objectFactory); }
Example #8
Source File: WrappedNativeLibraryPlugin.java From native-samples with Apache License 2.0 | 5 votes |
public DefaultMainPublication(Provider<String> baseName, Usage apiUsage, Configuration api, ImmutableAttributesFactory immutableAttributesFactory, ObjectFactory objectFactory) { this.baseName = baseName; AttributeContainer publicationAttributes = immutableAttributesFactory.mutable(); publicationAttributes.attribute(Usage.USAGE_ATTRIBUTE, apiUsage); publicationAttributes.attribute(ArtifactAttributes.ARTIFACT_FORMAT, ZIP_TYPE); this.mainVariant = new MainLibraryVariant("api", apiUsage, api, publicationAttributes, objectFactory); }
Example #9
Source File: WrappedNativeLibraryPlugin.java From native-samples with Apache License 2.0 | 5 votes |
public DefaultMainPublication(Provider<String> baseName, Usage apiUsage, Configuration api, ImmutableAttributesFactory immutableAttributesFactory, ObjectFactory objectFactory) { this.baseName = baseName; AttributeContainer publicationAttributes = immutableAttributesFactory.mutable(); publicationAttributes.attribute(Usage.USAGE_ATTRIBUTE, apiUsage); publicationAttributes.attribute(ArtifactAttributes.ARTIFACT_FORMAT, ZIP_TYPE); this.mainVariant = new MainLibraryVariant("api", apiUsage, api, publicationAttributes, objectFactory); }
Example #10
Source File: WrappedNativeLibraryPlugin.java From native-samples with Apache License 2.0 | 5 votes |
public DefaultMainPublication(Provider<String> baseName, Usage apiUsage, Configuration api, ImmutableAttributesFactory immutableAttributesFactory, ObjectFactory objectFactory) { this.baseName = baseName; AttributeContainer publicationAttributes = immutableAttributesFactory.mutable(); publicationAttributes.attribute(Usage.USAGE_ATTRIBUTE, apiUsage); publicationAttributes.attribute(ArtifactAttributes.ARTIFACT_FORMAT, ZIP_TYPE); this.mainVariant = new MainLibraryVariant("api", apiUsage, api, publicationAttributes, objectFactory); }
Example #11
Source File: AtlasDependencyGraph.java From atlas with Apache License 2.0 | 4 votes |
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; }