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