mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Move UI bundle URL to package.json
Closes gh-40132
This commit is contained in:
parent
0ff402ac7b
commit
5282d9878e
|
@ -11,5 +11,8 @@
|
|||
"@springio/antora-zip-contents-collector-extension": "1.0.0-alpha.2",
|
||||
"@asciidoctor/tabs": "1.0.0-beta.6",
|
||||
"@springio/asciidoctor-extensions": "1.0.0-alpha.10"
|
||||
},
|
||||
"config": {
|
||||
"ui-bundle-url": "https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.11/ui-bundle.zip"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
package org.springframework.boot.build;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.gradle.node.NodeExtension;
|
||||
import com.github.gradle.node.npm.task.NpmInstallTask;
|
||||
import io.spring.gradle.antora.GenerateAntoraYmlPlugin;
|
||||
|
@ -40,6 +43,7 @@ import org.springframework.boot.build.antora.GenerateAntoraPlaybook;
|
|||
import org.springframework.boot.build.bom.BomExtension;
|
||||
import org.springframework.boot.build.constraints.ExtractVersionConstraints;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Conventions that are applied in the presence of the {@link AntoraPlugin}.
|
||||
|
@ -147,6 +151,7 @@ public class AntoraConventions {
|
|||
antoraTask.setGroup("Documentation");
|
||||
antoraTask.dependsOn(npmInstallTask, generateAntoraPlaybookTask);
|
||||
antoraTask.setPlaybook("antora-playbook.yml");
|
||||
antoraTask.setUiBundleUrl(getUiBundleUrl(project));
|
||||
project.getPlugins()
|
||||
.withType(JavaBasePlugin.class,
|
||||
(javaBasePlugin) -> project.getTasks()
|
||||
|
@ -154,6 +159,21 @@ public class AntoraConventions {
|
|||
.dependsOn(antoraTask));
|
||||
}
|
||||
|
||||
private String getUiBundleUrl(Project project) {
|
||||
try {
|
||||
File packageJson = project.getRootProject().file("antora/package.json");
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<?, ?> json = objectMapper.readerFor(Map.class).readValue(packageJson);
|
||||
Map<?, ?> config = (json != null) ? (Map<?, ?>) json.get("config") : null;
|
||||
String url = (config != null) ? (String) config.get("ui-bundle-url") : null;
|
||||
Assert.state(StringUtils.hasText(url.toString()), "package.json has not ui-bundle-url config");
|
||||
return url;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void configureAntoraExtension(Project project, AntoraExtension antoraExtension) {
|
||||
if (project.getGradle().getStartParameter().getLogLevel() != LogLevel.DEBUG) {
|
||||
antoraExtension.getOptions().add("--quiet");
|
||||
|
|
|
@ -22,6 +22,3 @@ urls:
|
|||
runtime:
|
||||
log:
|
||||
failure_level: warn
|
||||
ui:
|
||||
bundle:
|
||||
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.11/ui-bundle.zip
|
|
@ -43,8 +43,5 @@ urls:
|
|||
runtime:
|
||||
log:
|
||||
failure_level: warn
|
||||
ui:
|
||||
bundle:
|
||||
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.11/ui-bundle.zip
|
||||
output:
|
||||
dir: ./../../../site
|
||||
|
|
Loading…
Reference in New Issue
Block a user