mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Ensure that extensions have been built before Asciidoctor runs
See gh-40536
This commit is contained in:
parent
d01a049dd1
commit
436f2758f8
@ -26,6 +26,7 @@ import org.asciidoctor.gradle.jvm.AsciidoctorJExtension;
|
|||||||
import org.asciidoctor.gradle.jvm.AsciidoctorJPlugin;
|
import org.asciidoctor.gradle.jvm.AsciidoctorJPlugin;
|
||||||
import org.asciidoctor.gradle.jvm.AsciidoctorTask;
|
import org.asciidoctor.gradle.jvm.AsciidoctorTask;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
|
import org.gradle.api.artifacts.Configuration;
|
||||||
import org.gradle.api.tasks.PathSensitivity;
|
import org.gradle.api.tasks.PathSensitivity;
|
||||||
import org.gradle.api.tasks.Sync;
|
import org.gradle.api.tasks.Sync;
|
||||||
|
|
||||||
@ -54,6 +55,9 @@ import org.springframework.util.StringUtils;
|
|||||||
* <li>{@link AbstractAsciidoctorTask#baseDirFollowsSourceDir() baseDirFollowsSourceDir()}
|
* <li>{@link AbstractAsciidoctorTask#baseDirFollowsSourceDir() baseDirFollowsSourceDir()}
|
||||||
* is enabled.
|
* is enabled.
|
||||||
* <li>{@code asciidoctorExtensions} is added to the task's configurations.
|
* <li>{@code asciidoctorExtensions} is added to the task's configurations.
|
||||||
|
* <li>The task is configured to depend on the {@code asciidoctorExtensions} configuraion
|
||||||
|
* to ensure that any extensions are built before the task runs. This works around
|
||||||
|
* https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/721.
|
||||||
* </ul>
|
* </ul>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
@ -64,16 +68,14 @@ class AsciidoctorConventions {
|
|||||||
|
|
||||||
private static final String ASCIIDOCTORJ_VERSION = "2.4.3";
|
private static final String ASCIIDOCTORJ_VERSION = "2.4.3";
|
||||||
|
|
||||||
private static final String EXTENSIONS_CONFIGURATION_NAME = "asciidoctorExtensions";
|
|
||||||
|
|
||||||
void apply(Project project) {
|
void apply(Project project) {
|
||||||
project.getPlugins().withType(AsciidoctorJPlugin.class, (asciidoctorPlugin) -> {
|
project.getPlugins().withType(AsciidoctorJPlugin.class, (asciidoctorPlugin) -> {
|
||||||
makeAllWarningsFatal(project);
|
makeAllWarningsFatal(project);
|
||||||
upgradeAsciidoctorJVersion(project);
|
upgradeAsciidoctorJVersion(project);
|
||||||
createAsciidoctorExtensionsConfiguration(project);
|
Configuration asciidoctorExtensions = createAsciidoctorExtensionsConfiguration(project);
|
||||||
project.getTasks()
|
project.getTasks()
|
||||||
.withType(AbstractAsciidoctorTask.class,
|
.withType(AbstractAsciidoctorTask.class,
|
||||||
(asciidoctorTask) -> configureAsciidoctorTask(project, asciidoctorTask));
|
(asciidoctorTask) -> configureAsciidoctorTask(project, asciidoctorTask, asciidoctorExtensions));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +87,8 @@ class AsciidoctorConventions {
|
|||||||
project.getExtensions().getByType(AsciidoctorJExtension.class).setVersion(ASCIIDOCTORJ_VERSION);
|
project.getExtensions().getByType(AsciidoctorJExtension.class).setVersion(ASCIIDOCTORJ_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAsciidoctorExtensionsConfiguration(Project project) {
|
private Configuration createAsciidoctorExtensionsConfiguration(Project project) {
|
||||||
project.getConfigurations().create(EXTENSIONS_CONFIGURATION_NAME, (configuration) -> {
|
return project.getConfigurations().create("asciidoctorExtensions", (configuration) -> {
|
||||||
project.getConfigurations()
|
project.getConfigurations()
|
||||||
.matching((candidate) -> "dependencyManagement".equals(candidate.getName()))
|
.matching((candidate) -> "dependencyManagement".equals(candidate.getName()))
|
||||||
.all(configuration::extendsFrom);
|
.all(configuration::extendsFrom);
|
||||||
@ -98,8 +100,10 @@ class AsciidoctorConventions {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureAsciidoctorTask(Project project, AbstractAsciidoctorTask asciidoctorTask) {
|
private void configureAsciidoctorTask(Project project, AbstractAsciidoctorTask asciidoctorTask,
|
||||||
asciidoctorTask.configurations(EXTENSIONS_CONFIGURATION_NAME);
|
Configuration asciidoctorExtensions) {
|
||||||
|
asciidoctorTask.configurations(asciidoctorExtensions);
|
||||||
|
asciidoctorTask.dependsOn(asciidoctorExtensions);
|
||||||
configureCommonAttributes(project, asciidoctorTask);
|
configureCommonAttributes(project, asciidoctorTask);
|
||||||
configureOptions(asciidoctorTask);
|
configureOptions(asciidoctorTask);
|
||||||
configureForkOptions(asciidoctorTask);
|
configureForkOptions(asciidoctorTask);
|
||||||
|
Loading…
Reference in New Issue
Block a user