Attempt to fix Windows build error

See gh-33766
This commit is contained in:
Phillip Webb 2024-03-20 16:32:31 -07:00
parent 66dc3edb34
commit 0c0fa1bc70
2 changed files with 8 additions and 7 deletions

View File

@ -135,7 +135,7 @@ public abstract class GenerateAntoraPlaybook extends DefaultTask {
Path playbookPath = getOutputFile().get().getAsFile().toPath().getParent();
Path antoraSrc = getProjectPath(getProject()).resolve(ANTORA_SOURCE_DIR);
StringBuilder url = new StringBuilder(".");
relativizeFromRootProject(playbookPath).normalize().forEach((path) -> url.append("/.."));
relativizeFromRootProject(playbookPath).normalize().forEach((path) -> url.append(File.separator).append(".."));
source.put("url", url.toString());
source.put("branches", "HEAD");
source.put("version", getProject().getVersion().toString());
@ -159,7 +159,7 @@ public abstract class GenerateAntoraPlaybook extends DefaultTask {
private void addDir(Map<String, Object> data) {
Path playbookDir = toRealPath(getOutputFile().get().getAsFile().toPath()).getParent();
Path outputDir = toRealPath(getProject().getBuildDir().toPath().resolve("site"));
data.put("output", Map.of("dir", "./" + playbookDir.relativize(outputDir).toString()));
data.put("output", Map.of("dir", "." + File.separator + playbookDir.relativize(outputDir).toString()));
}
@SuppressWarnings("unchecked")

View File

@ -46,11 +46,12 @@ class GenerateAntoraPlaybookTests {
task.getXrefStubs().addAll("appendix:.*", "api:.*", "reference:.*");
task.getAlwaysInclude().set(Map.of("name", "test", "classifier", "local-aggregate-content"));
});
Path actual = this.temp.toPath()
.resolve("rootproject/project/build/generated/docs/antora-playbook/antora-playbook.yml");
System.out.println(Files.readString(actual));
assertThat(actual).hasSameTextualContentAs(
Path.of("src/test/resources/org/springframework/boot/build/antora/expected-playbook.yml"));
String actual = Files.readString(this.temp.toPath()
.resolve("rootproject/project/build/generated/docs/antora-playbook/antora-playbook.yml"));
String expected = Files
.readString(Path.of("src/test/resources/org/springframework/boot/build/antora/expected-playbook.yml"));
System.out.println(actual);
assertThat(actual).isEqualToNormalizingNewlines(expected);
}
private void writePlaybookYml(ThrowingConsumer<GenerateAntoraPlaybook> customizer) throws Exception {