Search in sources :

Example 1 with GenerateDefaultImports

use of gradlebuild.docs.dsl.source.GenerateDefaultImports in project gradle by gradle.

the class GradleUserManualPlugin method generateDefaultImports.

// TODO: This doesn't really make sense to be part of the user manual generation, but it's so tied up into it
// it's left here for a future project.
private void generateDefaultImports(Project project, TaskContainer tasks, GradleDocumentationExtension extension) {
    List<String> excludedPackages = getDefaultExcludedPackages();
    Provider<Directory> generatedDirectory = extension.getUserManual().getStagingRoot().dir("generated");
    TaskProvider<GenerateApiMapping> apiMapping = tasks.register("apiMapping", GenerateApiMapping.class, task -> {
        task.getMetaDataFile().convention(extension.getDslReference().getGeneratedMetaDataFile());
        task.getMappingDestFile().convention(generatedDirectory.map(dir -> dir.file("api-mapping.txt")));
        task.getExcludedPackages().convention(excludedPackages);
    });
    TaskProvider<GenerateDefaultImports> defaultImports = tasks.register("defaultImports", GenerateDefaultImports.class, task -> {
        task.getMetaDataFile().convention(extension.getDslReference().getGeneratedMetaDataFile());
        task.getImportsDestFile().convention(generatedDirectory.map(dir -> dir.file("default-imports.txt")));
        task.getExcludedPackages().convention(excludedPackages);
    });
    SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
    sourceSets.getByName("main", main -> main.getOutput().dir(singletonMap("builtBy", asList(apiMapping, defaultImports)), generatedDirectory));
    extension.getUserManual().getResources().from(apiMapping);
    extension.getUserManual().getResources().from(defaultImports);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) LifecycleBasePlugin(org.gradle.language.base.plugins.LifecycleBasePlugin) Provider(org.gradle.api.provider.Provider) RelativePath(org.gradle.api.file.RelativePath) Sync(org.gradle.api.tasks.Sync) AsciidoctorTask(org.asciidoctor.gradle.jvm.AsciidoctorTask) TaskProvider(org.gradle.api.tasks.TaskProvider) DirectoryProperty(org.gradle.api.file.DirectoryProperty) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) Arrays.asList(java.util.Arrays.asList) PathSensitivity(org.gradle.api.tasks.PathSensitivity) Map(java.util.Map) DuplicatesStrategy(org.gradle.api.file.DuplicatesStrategy) Collections.singletonMap(java.util.Collections.singletonMap) Directory(org.gradle.api.file.Directory) TaskInputs(org.gradle.api.tasks.TaskInputs) Project(org.gradle.api.Project) List(java.util.List) ProjectLayout(org.gradle.api.file.ProjectLayout) TaskContainer(org.gradle.api.tasks.TaskContainer) GenerateApiMapping(gradlebuild.docs.dsl.source.GenerateApiMapping) GenerateDefaultImports(gradlebuild.docs.dsl.source.GenerateDefaultImports) Plugin(org.gradle.api.Plugin) GenerateDefaultImports(gradlebuild.docs.dsl.source.GenerateDefaultImports) GenerateApiMapping(gradlebuild.docs.dsl.source.GenerateApiMapping) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) Directory(org.gradle.api.file.Directory)

Aggregations

GenerateApiMapping (gradlebuild.docs.dsl.source.GenerateApiMapping)1 GenerateDefaultImports (gradlebuild.docs.dsl.source.GenerateDefaultImports)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 Collections.singletonMap (java.util.Collections.singletonMap)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 AsciidoctorTask (org.asciidoctor.gradle.jvm.AsciidoctorTask)1 Plugin (org.gradle.api.Plugin)1 Project (org.gradle.api.Project)1 Directory (org.gradle.api.file.Directory)1 DirectoryProperty (org.gradle.api.file.DirectoryProperty)1 DuplicatesStrategy (org.gradle.api.file.DuplicatesStrategy)1 ProjectLayout (org.gradle.api.file.ProjectLayout)1 RelativePath (org.gradle.api.file.RelativePath)1 Provider (org.gradle.api.provider.Provider)1 PathSensitivity (org.gradle.api.tasks.PathSensitivity)1 SourceSetContainer (org.gradle.api.tasks.SourceSetContainer)1