Search in sources :

Example 26 with AttributeContainer

use of org.gradle.api.attributes.AttributeContainer in project MyLuaApp-Build-Core by dingyi222666.

the class AttributeDesugaring method desugarSelector.

public ComponentSelector desugarSelector(ComponentSelector selector) {
    if (selector instanceof ModuleComponentSelector) {
        ModuleComponentSelector module = (ModuleComponentSelector) selector;
        AttributeContainer moduleAttributes = module.getAttributes();
        if (!moduleAttributes.isEmpty()) {
            ImmutableAttributes attributes = ((AttributeContainerInternal) moduleAttributes).asImmutable();
            return DefaultModuleComponentSelector.newSelector(module.getModuleIdentifier(), module.getVersionConstraint(), desugar(attributes), module.getRequestedCapabilities());
        }
    }
    if (selector instanceof DefaultProjectComponentSelector) {
        DefaultProjectComponentSelector project = (DefaultProjectComponentSelector) selector;
        AttributeContainer projectAttributes = project.getAttributes();
        if (!projectAttributes.isEmpty()) {
            ImmutableAttributes attributes = ((AttributeContainerInternal) projectAttributes).asImmutable();
            return new DefaultProjectComponentSelector(project.getBuildIdentifier(), project.getIdentityPath(), project.projectPath(), project.getProjectName(), desugar(attributes), project.getRequestedCapabilities());
        }
    }
    return selector;
}
Also used : DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) AttributeContainer(org.gradle.api.attributes.AttributeContainer)

Example 27 with AttributeContainer

use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.

the class ResolvedVariantResultSerializer method read.

@Override
public ResolvedVariantResult read(Decoder decoder) throws IOException {
    int index = decoder.readSmallInt();
    if (index == -1) {
        return null;
    }
    if (index == read.size()) {
        ComponentIdentifier owner = componentIdentifierSerializer.read(decoder);
        String variantName = decoder.readString();
        AttributeContainer attributes = attributeContainerSerializer.read(decoder);
        List<Capability> capabilities = readCapabilities(decoder);
        read.add(null);
        ResolvedVariantResult externalVariant = read(decoder);
        DefaultResolvedVariantResult result = new DefaultResolvedVariantResult(owner, Describables.of(variantName), attributes, capabilities, externalVariant);
        this.read.set(index, result);
        return result;
    }
    return read.get(index);
}
Also used : Capability(org.gradle.api.capabilities.Capability) DefaultResolvedVariantResult(org.gradle.api.internal.artifacts.result.DefaultResolvedVariantResult) DefaultResolvedVariantResult(org.gradle.api.internal.artifacts.result.DefaultResolvedVariantResult) ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) AttributeContainer(org.gradle.api.attributes.AttributeContainer)

Example 28 with AttributeContainer

use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.

the class ComponentMetadataDetailsAdapter method attributes.

@Override
public ComponentMetadataDetails attributes(Action<? super AttributeContainer> action) {
    AttributeContainer attributes = metadata.getAttributesFactory().mutable((AttributeContainerInternal) metadata.getAttributes());
    action.execute(attributes);
    metadata.setAttributes(attributes);
    return this;
}
Also used : AttributeContainer(org.gradle.api.attributes.AttributeContainer)

Example 29 with AttributeContainer

use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.

the class ConsumerProvidedVariantFinder method matchAttributes.

private boolean matchAttributes(AttributeContainerInternal actual, AttributeContainerInternal requested) {
    AttributeMatcher schemaToMatchOn = schema.matcher();
    Map<AttributeContainer, Boolean> cache = getCache(requested).ignoreExtraActual;
    Boolean match = cache.get(actual);
    if (match == null) {
        match = schemaToMatchOn.isMatching(actual, requested);
        cache.put(actual, match);
    }
    return match;
}
Also used : AttributeMatcher(org.gradle.internal.component.model.AttributeMatcher) AttributeContainer(org.gradle.api.attributes.AttributeContainer)

Example 30 with AttributeContainer

use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.

the class DefaultScriptHandler method defineConfiguration.

private void defineConfiguration() {
    // Defer creation and resolution of configuration until required. Short-circuit when script does not require classpath
    if (configContainer == null) {
        configContainer = dependencyResolutionServices.getConfigurationContainer();
    }
    if (dependencyHandler == null) {
        dependencyHandler = dependencyResolutionServices.getDependencyHandler();
    }
    if (classpathConfiguration == null) {
        classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION);
        // should ideally reuse the `JvmEcosystemUtilities` but this code is too low level
        // and this service is therefore not available!
        AttributeContainer attributes = classpathConfiguration.getAttributes();
        attributes.attribute(Usage.USAGE_ATTRIBUTE, instantiator.named(Usage.class, Usage.JAVA_RUNTIME));
        attributes.attribute(Category.CATEGORY_ATTRIBUTE, instantiator.named(Category.class, Category.LIBRARY));
        attributes.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, instantiator.named(LibraryElements.class, LibraryElements.JAR));
        attributes.attribute(Bundling.BUNDLING_ATTRIBUTE, instantiator.named(Bundling.class, Bundling.EXTERNAL));
        attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, Integer.parseInt(JavaVersion.current().getMajorVersion()));
        attributes.attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, instantiator.named(GradlePluginApiVersion.class, GradleVersion.current().getVersion()));
        classpathConfiguration.getDependencyConstraints().add(dependencyHandler.getConstraints().create(Log4jBannedVersion.LOG4J2_CORE_COORDINATES, constraint -> constraint.version(version -> {
            version.require(Log4jBannedVersion.LOG4J2_CORE_REQUIRED_VERSION);
            version.reject(Log4jBannedVersion.LOG4J2_CORE_VULNERABLE_VERSION_RANGE);
        })));
    }
}
Also used : Bundling(org.gradle.api.attributes.Bundling) NamedObjectInstantiator(org.gradle.api.internal.model.NamedObjectInstantiator) RepositoryHandler(org.gradle.api.artifacts.dsl.RepositoryHandler) JavaEcosystemSupport(org.gradle.api.internal.artifacts.JavaEcosystemSupport) Category(org.gradle.api.attributes.Category) BeanDynamicObject(org.gradle.internal.metaobject.BeanDynamicObject) Closure(groovy.lang.Closure) DynamicObjectAware(org.gradle.api.internal.DynamicObjectAware) Logger(org.gradle.api.logging.Logger) LibraryElements(org.gradle.api.attributes.LibraryElements) Bundling(org.gradle.api.attributes.Bundling) ConfigureUtil(org.gradle.util.internal.ConfigureUtil) Configuration(org.gradle.api.artifacts.Configuration) TargetJvmVersion(org.gradle.api.attributes.java.TargetJvmVersion) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) AttributeContainer(org.gradle.api.attributes.AttributeContainer) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) Log4jBannedVersion(org.gradle.internal.logging.util.Log4jBannedVersion) URI(java.net.URI) GradleVersion(org.gradle.util.GradleVersion) DependencyLockingHandler(org.gradle.api.artifacts.dsl.DependencyLockingHandler) Usage(org.gradle.api.attributes.Usage) GradlePluginApiVersion(org.gradle.api.attributes.plugin.GradlePluginApiVersion) JavaVersion(org.gradle.api.JavaVersion) File(java.io.File) DependencyResolutionServices(org.gradle.api.internal.artifacts.DependencyResolutionServices) ScriptSource(org.gradle.groovy.scripts.ScriptSource) ResourceLocation(org.gradle.internal.resource.ResourceLocation) Logging(org.gradle.api.logging.Logging) DynamicObject(org.gradle.internal.metaobject.DynamicObject) ClassPath(org.gradle.internal.classpath.ClassPath) ScriptHandler(org.gradle.api.initialization.dsl.ScriptHandler) ClasspathUtil(org.gradle.internal.classloader.ClasspathUtil) Usage(org.gradle.api.attributes.Usage) Category(org.gradle.api.attributes.Category) GradlePluginApiVersion(org.gradle.api.attributes.plugin.GradlePluginApiVersion) AttributeContainer(org.gradle.api.attributes.AttributeContainer) LibraryElements(org.gradle.api.attributes.LibraryElements)

Aggregations

AttributeContainer (org.gradle.api.attributes.AttributeContainer)34 Usage (org.gradle.api.attributes.Usage)14 Configuration (org.gradle.api.artifacts.Configuration)13 Project (org.gradle.api.Project)7 DefaultUsageContext (org.gradle.language.cpp.internal.DefaultUsageContext)7 NativeVariantIdentity (org.gradle.language.cpp.internal.NativeVariantIdentity)7 Bundling (org.gradle.api.attributes.Bundling)6 Callable (java.util.concurrent.Callable)5 Action (org.gradle.api.Action)5 ObjectFactory (org.gradle.api.model.ObjectFactory)5 Provider (org.gradle.api.provider.Provider)5 OperatingSystemFamily (org.gradle.nativeplatform.OperatingSystemFamily)5 File (java.io.File)4 Set (java.util.Set)4 Attribute (org.gradle.api.attributes.Attribute)4 Category (org.gradle.api.attributes.Category)4 Task (org.gradle.api.Task)3 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)3 LibraryElements (org.gradle.api.attributes.LibraryElements)3 Capability (org.gradle.api.capabilities.Capability)3