Move common Asciidoctor configuration into our conventions

Closes gh-26620
pull/27348/head
Andy Wilkinson 3 years ago
parent 8ce7a2b5a3
commit a1c5fcca58

@ -46,8 +46,15 @@ import org.springframework.util.StringUtils;
* the plugin is applied:
*
* <ul>
* <li>The {@code https://repo.spring.io/release} Maven repository is configured and
* limited to dependencies in the following groups:
* <ul>
* <li>{@code io.spring.asciidoctor}
* <li>{@code io.spring.docresources}
* </ul>
* <li>All warnings are made fatal.
* <li>The version of AsciidoctorJ is upgraded to 2.4.1.
* <li>An {@code asciidoctorExtensions} configuration is created.
* <li>A task is created to resolve and unzip our documentation resources (CSS and
* Javascript).
* <li>For each {@link AsciidoctorTask} (HTML only):
@ -64,6 +71,7 @@ import org.springframework.util.StringUtils;
* the current version, etc.
* <li>{@link AbstractAsciidoctorTask#baseDirFollowsSourceDir() baseDirFollowsSourceDir()}
* is enabled.
* <li>{@code asciidoctorExtensions} is added to the task's configurations.
* </ul>
* </ul>
*
@ -73,16 +81,20 @@ class AsciidoctorConventions {
private static final String ASCIIDOCTORJ_VERSION = "2.4.1";
private static final String EXTENSIONS_CONFIGURATION_NAME = "asciidoctorExtensions";
void apply(Project project) {
project.getPlugins().withType(AsciidoctorJPlugin.class, (asciidoctorPlugin) -> {
configureDocResourcesRepository(project);
configureDocumentationDependenciesRepository(project);
makeAllWarningsFatal(project);
upgradeAsciidoctorJVersion(project);
Configuration asciidoctorExtensions = createAsciidoctorExtensionsConfiguration(project);
UnzipDocumentationResources unzipResources = createUnzipDocumentationResourcesTask(project);
project.getTasks().withType(AbstractAsciidoctorTask.class, (asciidoctorTask) -> {
configureCommonAttributes(project, asciidoctorTask);
configureOptions(asciidoctorTask);
asciidoctorTask.baseDirFollowsSourceDir();
asciidoctorTask.configurations(asciidoctorExtensions);
Sync syncSource = createSyncDocumentationSourceTask(project, asciidoctorTask);
if (asciidoctorTask instanceof AsciidoctorTask) {
configureHtmlOnlyAttributes(asciidoctorTask);
@ -104,10 +116,13 @@ class AsciidoctorConventions {
});
}
private void configureDocResourcesRepository(Project project) {
private void configureDocumentationDependenciesRepository(Project project) {
project.getRepositories().maven((mavenRepo) -> {
mavenRepo.setUrl(URI.create("https://repo.spring.io/release"));
mavenRepo.mavenContent((mavenContent) -> mavenContent.includeGroup("io.spring.docresources"));
mavenRepo.mavenContent((mavenContent) -> {
mavenContent.includeGroup("io.spring.asciidoctor");
mavenContent.includeGroup("io.spring.docresources");
});
});
}
@ -119,6 +134,13 @@ class AsciidoctorConventions {
project.getExtensions().getByType(AsciidoctorJExtension.class).setVersion(ASCIIDOCTORJ_VERSION);
}
private Configuration createAsciidoctorExtensionsConfiguration(Project project) {
return project.getConfigurations().create(EXTENSIONS_CONFIGURATION_NAME,
(configuration) -> project.getConfigurations()
.matching((candidate) -> "dependencyManagement".equals(candidate.getName()))
.all((dependencyManagement) -> configuration.extendsFrom(dependencyManagement)));
}
private UnzipDocumentationResources createUnzipDocumentationResourcesTask(Project project) {
Configuration documentationResources = project.getConfigurations().maybeCreate("documentationResources");
documentationResources.getDependencies()

@ -11,9 +11,6 @@ plugins {
description = "Spring Boot Actuator AutoConfigure"
configurations {
asciidoctorExtensions {
extendsFrom dependencyManagement
}
documentation
}
@ -158,7 +155,6 @@ task dependencyVersions(type: org.springframework.boot.build.constraints.Extract
tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
dependsOn dependencyVersions
baseDirFollowsSourceDir()
doFirst {
def versionConstraints = dependencyVersions.versionConstraints
def integrationVersion = versionConstraints["org.springframework.integration:spring-integration-core"]
@ -170,14 +166,12 @@ tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
}
asciidoctor {
configurations "asciidoctorExtensions"
sources {
include "index.adoc"
}
}
asciidoctorPdf {
configurations "asciidoctorExtensions"
sources {
include "index.adoc"
}

@ -10,9 +10,6 @@ description = "Spring Boot Docs"
configurations {
actuatorApiDocumentation
asciidoctorExtensions {
extendsFrom dependencyManagement
}
autoConfiguration
configurationProperties
gradlePluginDocumentation
@ -20,15 +17,6 @@ configurations {
testSlices
}
repositories {
maven {
url "https://repo.spring.io/release"
mavenContent {
includeGroup "io.spring.asciidoctor"
}
}
}
jar {
enabled = false
}
@ -187,8 +175,6 @@ task documentConfigurationProperties(type: org.springframework.boot.build.contex
tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
dependsOn dependencyVersions
configurations "asciidoctorExtensions"
baseDirFollowsSourceDir()
asciidoctorj {
fatalWarnings = ['^((?!successfully validated).)*$']
}

@ -15,21 +15,9 @@ toolchain {
}
configurations {
asciidoctorExtensions {
extendsFrom dependencyManagement
}
documentation
}
repositories {
maven {
url "https://repo.spring.io/release"
mavenContent {
includeGroup "io.spring.asciidoctor"
}
}
}
dependencies {
asciidoctorExtensions("io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch")
@ -85,7 +73,6 @@ tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
}
asciidoctor {
configurations "asciidoctorExtensions"
sources {
include "index.adoc"
}

Loading…
Cancel
Save