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