Search in sources :

Example 1 with DocsType

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

Aggregations

Task (org.gradle.api.Task)1 Configuration (org.gradle.api.artifacts.Configuration)1 AttributeContainer (org.gradle.api.attributes.AttributeContainer)1 Bundling (org.gradle.api.attributes.Bundling)1 Category (org.gradle.api.attributes.Category)1 DocsType (org.gradle.api.attributes.DocsType)1 Usage (org.gradle.api.attributes.Usage)1 LazyPublishArtifact (org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact)1 Jar (org.gradle.api.tasks.bundling.Jar)1