Search in sources :

Example 21 with AttributeContainer

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

the class JvmPluginsHelper method configureDocumentationVariantWithArtifact.

public static void configureDocumentationVariantWithArtifact(String variantName, @Nullable String featureName, String docsType, List<Capability> capabilities, String jarTaskName, Object artifactSource, @Nullable AdhocComponentWithVariants component, ConfigurationContainer configurations, TaskContainer tasks, ObjectFactory objectFactory) {
    Configuration variant = maybeCreateInvisibleConfig(configurations, variantName, docsType + " elements for " + (featureName == null ? "main" : featureName) + ".", true);
    AttributeContainer attributes = variant.getAttributes();
    attributes.attribute(Usage.USAGE_ATTRIBUTE, objectFactory.named(Usage.class, Usage.JAVA_RUNTIME));
    attributes.attribute(Category.CATEGORY_ATTRIBUTE, objectFactory.named(Category.class, Category.DOCUMENTATION));
    attributes.attribute(Bundling.BUNDLING_ATTRIBUTE, objectFactory.named(Bundling.class, Bundling.EXTERNAL));
    attributes.attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objectFactory.named(DocsType.class, docsType));
    capabilities.forEach(variant.getOutgoing()::capability);
    if (!tasks.getNames().contains(jarTaskName)) {
        TaskProvider<Jar> jarTask = tasks.register(jarTaskName, Jar.class, jar -> {
            jar.setDescription("Assembles a jar archive containing the " + (featureName == null ? "main " + docsType + "." : (docsType + " of the '" + featureName + "' feature.")));
            jar.setGroup(BasePlugin.BUILD_GROUP);
            jar.from(artifactSource);
            jar.getArchiveClassifier().set(camelToKebabCase(featureName == null ? docsType : (featureName + "-" + docsType)));
        });
        if (tasks.getNames().contains(LifecycleBasePlugin.ASSEMBLE_TASK_NAME)) {
            tasks.named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).configure(task -> task.dependsOn(jarTask));
        }
    }
    TaskProvider<Task> jar = tasks.named(jarTaskName);
    variant.getOutgoing().artifact(new LazyPublishArtifact(jar));
    if (component != null) {
        component.addVariantsFromConfiguration(variant, new JavaConfigurationVariantMapping("runtime", true));
    }
}
Also used : Bundling(org.gradle.api.attributes.Bundling) Usage(org.gradle.api.attributes.Usage) Task(org.gradle.api.Task) Category(org.gradle.api.attributes.Category) LazyPublishArtifact(org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact) Configuration(org.gradle.api.artifacts.Configuration) AttributeContainer(org.gradle.api.attributes.AttributeContainer) DocsType(org.gradle.api.attributes.DocsType) Jar(org.gradle.api.tasks.bundling.Jar)

Example 22 with AttributeContainer

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

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 (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()));
    }
}
Also used : Bundling(org.gradle.api.attributes.Bundling) 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)

Example 23 with AttributeContainer

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

the class NodeState method getResolvedVariant.

public ResolvedVariantResult getResolvedVariant() {
    if (cachedVariantResult != null) {
        return cachedVariantResult;
    }
    DisplayName name = Describables.of(metaData.getName());
    List<? extends Capability> capabilities = metaData.getCapabilities().getCapabilities();
    AttributeContainer attributes = desugar(metaData.getAttributes());
    List<Capability> resolvedVariantCapabilities = capabilities.isEmpty() ? Collections.singletonList(component.getImplicitCapability()) : ImmutableList.copyOf(capabilities);
    cachedVariantResult = new DefaultResolvedVariantResult(component.getComponentId(), name, attributes, resolvedVariantCapabilities, findExternalVariant());
    return cachedVariantResult;
}
Also used : Capability(org.gradle.api.capabilities.Capability) ShadowedCapability(org.gradle.internal.component.external.model.ShadowedCapability) DefaultResolvedVariantResult(org.gradle.api.internal.artifacts.result.DefaultResolvedVariantResult) DisplayName(org.gradle.internal.DisplayName) AttributeContainer(org.gradle.api.attributes.AttributeContainer)

Example 24 with AttributeContainer

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

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 25 with AttributeContainer

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

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)

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