Search in sources :

Example 1 with ModuleIdentityExtension

use of gradlebuild.identity.extension.ModuleIdentityExtension in project gradle by gradle.

the class GradleReleaseNotesPlugin method generateReleaseNotes.

private void generateReleaseNotes(Project project, ProjectLayout layout, TaskContainer tasks, GradleDocumentationExtension extension) {
    TaskProvider<RenderMarkdown> releaseNotesMarkdown = tasks.register("releaseNotesMarkdown", RenderMarkdown.class, task -> {
        task.setGroup("release notes");
        task.setDescription("Generate release notes HTML page from Markdown.");
        task.getInputEncoding().convention(Charset.defaultCharset().name());
        task.getOutputEncoding().convention(Charset.defaultCharset().name());
        task.getMarkdownFile().convention(extension.getReleaseNotes().getMarkdownFile());
        task.getDestinationFile().convention(extension.getStagingRoot().file("release-notes/raw.html"));
    });
    TaskProvider<DecorateReleaseNotes> releaseNotesPostProcess = tasks.register("releaseNotes", DecorateReleaseNotes.class, task -> {
        task.setGroup("release notes");
        task.setDescription("Transforms generated release notes.");
        task.getHtmlFile().convention(releaseNotesMarkdown.flatMap(RenderMarkdown::getDestinationFile));
        task.getBaseCssFile().convention(extension.getReleaseNotes().getBaseCssFile());
        task.getReleaseNotesCssFile().convention(extension.getReleaseNotes().getReleaseNotesCssFile());
        task.getReleaseNotesJavascriptFile().convention(extension.getReleaseNotes().getReleaseNotesJsFile());
        task.getJquery().from(extension.getReleaseNotes().getJquery());
        ModuleIdentityExtension moduleIdentity = project.getExtensions().getByType(ModuleIdentityExtension.class);
        MapProperty<String, String> replacementTokens = task.getReplacementTokens();
        replacementTokens.put("version", moduleIdentity.getVersion().map(GradleVersion::getVersion));
        replacementTokens.put("baseVersion", moduleIdentity.getVersion().map(v -> v.getBaseVersion().getVersion()));
        task.getDestinationFile().convention(extension.getStagingRoot().file("release-notes/release-notes.html"));
    });
    Configuration jquery = project.getConfigurations().create("jquery", conf -> {
        conf.setDescription("JQuery dependencies embedded by release notes.");
    });
    extension.releaseNotes(releaseNotes -> {
        releaseNotes.getMarkdownFile().convention(extension.getSourceRoot().file("release/notes.md"));
        releaseNotes.getRenderedDocumentation().convention(releaseNotesPostProcess.flatMap(DecorateReleaseNotes::getDestinationFile));
        releaseNotes.getBaseCssFile().convention(extension.getSourceRoot().file("css/base.css"));
        releaseNotes.getReleaseNotesCssFile().convention(extension.getSourceRoot().file("css/release-notes.css"));
        releaseNotes.getReleaseNotesJsFile().convention(extension.getSourceRoot().file("release/content/script.js"));
        releaseNotes.getJquery().from(jquery);
    });
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) ProjectLayout(org.gradle.api.file.ProjectLayout) TaskContainer(org.gradle.api.tasks.TaskContainer) Charset(java.nio.charset.Charset) Project(org.gradle.api.Project) MapProperty(org.gradle.api.provider.MapProperty) TaskProvider(org.gradle.api.tasks.TaskProvider) ModuleIdentityExtension(gradlebuild.identity.extension.ModuleIdentityExtension) Plugin(org.gradle.api.Plugin) GradleVersion(org.gradle.util.GradleVersion) Configuration(org.gradle.api.artifacts.Configuration) ModuleIdentityExtension(gradlebuild.identity.extension.ModuleIdentityExtension)

Aggregations

ModuleIdentityExtension (gradlebuild.identity.extension.ModuleIdentityExtension)1 Charset (java.nio.charset.Charset)1 Plugin (org.gradle.api.Plugin)1 Project (org.gradle.api.Project)1 Configuration (org.gradle.api.artifacts.Configuration)1 ProjectLayout (org.gradle.api.file.ProjectLayout)1 MapProperty (org.gradle.api.provider.MapProperty)1 TaskContainer (org.gradle.api.tasks.TaskContainer)1 TaskProvider (org.gradle.api.tasks.TaskProvider)1 GradleVersion (org.gradle.util.GradleVersion)1