Search in sources :

Example 6 with ProjectLayout

use of org.gradle.api.file.ProjectLayout in project gradle by gradle.

the class CheckstylePlugin method configureReportsConventionMapping.

private void configureReportsConventionMapping(Checkstyle task, final String baseName) {
    ProjectLayout layout = project.getLayout();
    ProviderFactory providers = project.getProviders();
    Provider<RegularFile> reportsDir = layout.file(providers.provider(() -> extension.getReportsDir()));
    task.getReports().all(action(report -> {
        report.getRequired().convention(true);
        report.getOutputLocation().convention(layout.getProjectDirectory().file(providers.provider(() -> {
            String reportFileName = baseName + "." + report.getName();
            return new File(reportsDir.get().getAsFile(), reportFileName).getAbsolutePath();
        })));
    }));
}
Also used : Callables(com.google.common.util.concurrent.Callables) TextResource(org.gradle.api.resources.TextResource) Callable(java.util.concurrent.Callable) SerializableLambdas.action(org.gradle.api.internal.lambdas.SerializableLambdas.action) ConventionMapping(org.gradle.api.internal.ConventionMapping) File(java.io.File) SourceSet(org.gradle.api.tasks.SourceSet) Configuration(org.gradle.api.artifacts.Configuration) ProviderFactory(org.gradle.api.provider.ProviderFactory) Provider(org.gradle.api.provider.Provider) ProjectLayout(org.gradle.api.file.ProjectLayout) RegularFile(org.gradle.api.file.RegularFile) Map(java.util.Map) AbstractCodeQualityPlugin(org.gradle.api.plugins.quality.internal.AbstractCodeQualityPlugin) Directory(org.gradle.api.file.Directory) RegularFile(org.gradle.api.file.RegularFile) ProjectLayout(org.gradle.api.file.ProjectLayout) ProviderFactory(org.gradle.api.provider.ProviderFactory) File(java.io.File) RegularFile(org.gradle.api.file.RegularFile)

Example 7 with ProjectLayout

use of org.gradle.api.file.ProjectLayout in project gradle by gradle.

the class CodeNarcPlugin method configureReportsConventionMapping.

private void configureReportsConventionMapping(CodeNarc task, final String baseName) {
    ProjectLayout layout = project.getLayout();
    ProviderFactory providers = project.getProviders();
    Provider<String> reportFormat = providers.provider(() -> extension.getReportFormat());
    Provider<RegularFile> reportsDir = layout.file(providers.provider(() -> extension.getReportsDir()));
    task.getReports().all(action(report -> {
        report.getRequired().convention(providers.provider(() -> report.getName().equals(reportFormat.get())));
        report.getOutputLocation().convention(layout.getProjectDirectory().file(providers.provider(() -> {
            String fileSuffix = report.getName().equals("text") ? "txt" : report.getName();
            return new File(reportsDir.get().getAsFile(), baseName + "." + fileSuffix).getAbsolutePath();
        })));
    }));
}
Also used : SourceDirectorySet(org.gradle.api.file.SourceDirectorySet) SerializableLambdas.action(org.gradle.api.internal.lambdas.SerializableLambdas.action) ConventionMapping(org.gradle.api.internal.ConventionMapping) File(java.io.File) SourceSet(org.gradle.api.tasks.SourceSet) Configuration(org.gradle.api.artifacts.Configuration) ProviderFactory(org.gradle.api.provider.ProviderFactory) Provider(org.gradle.api.provider.Provider) ProjectLayout(org.gradle.api.file.ProjectLayout) GroovyBasePlugin(org.gradle.api.plugins.GroovyBasePlugin) GroovySourceDirectorySet(org.gradle.api.tasks.GroovySourceDirectorySet) RegularFile(org.gradle.api.file.RegularFile) AbstractCodeQualityPlugin(org.gradle.api.plugins.quality.internal.AbstractCodeQualityPlugin) Plugin(org.gradle.api.Plugin) RegularFile(org.gradle.api.file.RegularFile) ProjectLayout(org.gradle.api.file.ProjectLayout) ProviderFactory(org.gradle.api.provider.ProviderFactory) File(java.io.File) RegularFile(org.gradle.api.file.RegularFile)

Example 8 with ProjectLayout

use of org.gradle.api.file.ProjectLayout in project gradle by gradle.

the class GradleBuildDocumentationPlugin method apply.

@Override
public void apply(Project project) {
    ProjectLayout layout = project.getLayout();
    TaskContainer tasks = project.getTasks();
    ObjectFactory objects = project.getObjects();
    ProviderFactory providers = project.getProviders();
    GradleDocumentationExtension extension = project.getExtensions().create("gradleDocumentation", GradleDocumentationExtension.class);
    applyConventions(project, tasks, objects, layout, extension);
    extension.getQuickFeedback().convention(providers.provider(() -> project.hasProperty("quickDocs")));
    project.apply(target -> target.plugin(GradleReleaseNotesPlugin.class));
    project.apply(target -> target.plugin(GradleJavadocsPlugin.class));
    project.apply(target -> target.plugin(GradleDslReferencePlugin.class));
    project.apply(target -> target.plugin(GradleUserManualPlugin.class));
    addUtilityTasks(tasks, extension);
    checkDocumentation(tasks, extension);
}
Also used : TaskContainer(org.gradle.api.tasks.TaskContainer) ObjectFactory(org.gradle.api.model.ObjectFactory) ProjectLayout(org.gradle.api.file.ProjectLayout) ProviderFactory(org.gradle.api.provider.ProviderFactory)

Example 9 with ProjectLayout

use of org.gradle.api.file.ProjectLayout in project gradle by gradle.

the class GradleBuildDocumentationPlugin method applyConventions.

private void applyConventions(Project project, TaskContainer tasks, ObjectFactory objects, ProjectLayout layout, GradleDocumentationExtension extension) {
    TaskProvider<Sync> stageDocs = tasks.register("stageDocs", Sync.class, task -> {
        // release notes goes in the root of the docs
        task.from(extension.getReleaseNotes().getRenderedDocumentation());
        // DSL reference goes into dsl/
        task.from(extension.getDslReference().getRenderedDocumentation(), sub -> sub.into("dsl"));
        // Javadocs reference goes into javadoc/
        task.from(extension.getJavadocs().getRenderedDocumentation(), sub -> sub.into("javadoc"));
        // User manual goes into userguide/ (for historical reasons)
        task.from(extension.getUserManual().getRenderedDocumentation(), sub -> sub.into("userguide"));
        task.into(extension.getDocumentationRenderedRoot());
    });
    extension.getSourceRoot().convention(layout.getProjectDirectory().dir("src/docs"));
    extension.getDocumentationRenderedRoot().convention(layout.getBuildDirectory().dir("docs"));
    extension.getStagingRoot().convention(layout.getBuildDirectory().dir("working"));
    ConfigurableFileTree css = objects.fileTree();
    css.from(extension.getSourceRoot().dir("css"));
    css.include("*.css");
    extension.getCssFiles().from(css);
    extension.getRenderedDocumentation().from(stageDocs);
    Configuration runtimeClasspath = project.getConfigurations().getByName("runtimeClasspath");
    Configuration sourcesPath = project.getConfigurations().create("sourcesPath");
    sourcesPath.attributes(a -> {
        a.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.class, Usage.JAVA_RUNTIME));
        a.attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.class, Category.DOCUMENTATION));
        a.attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.class, "gradle-source-folders"));
    });
    sourcesPath.setCanBeConsumed(false);
    sourcesPath.setCanBeResolved(true);
    sourcesPath.setVisible(false);
    sourcesPath.extendsFrom(runtimeClasspath);
    extension.getClasspath().from(runtimeClasspath);
    extension.getDocumentedSource().from(sourcesPath.getIncoming().artifactView(v -> v.lenient(true)).getFiles().getAsFileTree().matching(f -> {
        // Filter out any non-public APIs
        f.include(PublicApi.INSTANCE.getIncludes());
        f.exclude(PublicApi.INSTANCE.getExcludes());
    }));
}
Also used : PublicApi(gradlebuild.basics.PublicApi) Action(org.gradle.api.Action) Project(org.gradle.api.Project) Category(org.gradle.api.attributes.Category) DocsType(org.gradle.api.attributes.DocsType) ConfigurableFileTree(org.gradle.api.file.ConfigurableFileTree) Configuration(org.gradle.api.artifacts.Configuration) ProviderFactory(org.gradle.api.provider.ProviderFactory) Task(org.gradle.api.Task) ProjectLayout(org.gradle.api.file.ProjectLayout) Sync(org.gradle.api.tasks.Sync) ObjectFactory(org.gradle.api.model.ObjectFactory) TaskContainer(org.gradle.api.tasks.TaskContainer) TaskProvider(org.gradle.api.tasks.TaskProvider) PathSensitivity(org.gradle.api.tasks.PathSensitivity) Exec(org.gradle.api.tasks.Exec) Collections(java.util.Collections) Plugin(org.gradle.api.Plugin) Test(org.gradle.api.tasks.testing.Test) Usage(org.gradle.api.attributes.Usage) Usage(org.gradle.api.attributes.Usage) Category(org.gradle.api.attributes.Category) Configuration(org.gradle.api.artifacts.Configuration) ConfigurableFileTree(org.gradle.api.file.ConfigurableFileTree) DocsType(org.gradle.api.attributes.DocsType) Sync(org.gradle.api.tasks.Sync)

Example 10 with ProjectLayout

use of org.gradle.api.file.ProjectLayout in project gradle by gradle.

the class GradleDslReferencePlugin method apply.

@Override
public void apply(Project project) {
    ProjectLayout layout = project.getLayout();
    TaskContainer tasks = project.getTasks();
    ObjectFactory objects = project.getObjects();
    GradleDocumentationExtension extension = project.getExtensions().getByType(GradleDocumentationExtension.class);
    generateDslReference(project, layout, tasks, objects, extension);
}
Also used : TaskContainer(org.gradle.api.tasks.TaskContainer) ObjectFactory(org.gradle.api.model.ObjectFactory) ProjectLayout(org.gradle.api.file.ProjectLayout)

Aggregations

ProjectLayout (org.gradle.api.file.ProjectLayout)13 TaskContainer (org.gradle.api.tasks.TaskContainer)10 Plugin (org.gradle.api.Plugin)5 Configuration (org.gradle.api.artifacts.Configuration)5 ProviderFactory (org.gradle.api.provider.ProviderFactory)5 File (java.io.File)4 Project (org.gradle.api.Project)4 ObjectFactory (org.gradle.api.model.ObjectFactory)4 Provider (org.gradle.api.provider.Provider)4 TaskProvider (org.gradle.api.tasks.TaskProvider)4 Directory (org.gradle.api.file.Directory)3 RegularFile (org.gradle.api.file.RegularFile)3 ConventionMapping (org.gradle.api.internal.ConventionMapping)3 SerializableLambdas.action (org.gradle.api.internal.lambdas.SerializableLambdas.action)3 AbstractCodeQualityPlugin (org.gradle.api.plugins.quality.internal.AbstractCodeQualityPlugin)3 SourceSet (org.gradle.api.tasks.SourceSet)3 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Inject (javax.inject.Inject)2