use of org.gradle.api.attributes.DocsType in project gradle by gradle.
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, FileResolver fileResolver) {
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, fileResolver));
if (component != null) {
component.addVariantsFromConfiguration(variant, new JavaConfigurationVariantMapping("runtime", true));
}
}
Aggregations