|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2012-2024 the original author or authors. |
|
|
|
|
* Copyright 2012-2025 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -22,6 +22,8 @@ import java.io.FileWriter;
@@ -22,6 +22,8 @@ import java.io.FileWriter;
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.PrintWriter; |
|
|
|
|
import java.io.Reader; |
|
|
|
|
import java.io.UncheckedIOException; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Properties; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.SortedSet; |
|
|
|
|
@ -61,6 +63,8 @@ public abstract class DocumentAutoConfigurationClasses extends DefaultTask {
@@ -61,6 +63,8 @@ public abstract class DocumentAutoConfigurationClasses extends DefaultTask {
|
|
|
|
|
|
|
|
|
|
@TaskAction |
|
|
|
|
void documentAutoConfigurationClasses() throws IOException { |
|
|
|
|
List<AutoConfiguration> autoConfigurations = load(); |
|
|
|
|
autoConfigurations.forEach(this::writeModuleAdoc); |
|
|
|
|
for (File metadataFile : this.autoConfiguration) { |
|
|
|
|
Properties metadata = new Properties(); |
|
|
|
|
try (Reader reader = new FileReader(metadataFile)) { |
|
|
|
|
@ -68,15 +72,30 @@ public abstract class DocumentAutoConfigurationClasses extends DefaultTask {
@@ -68,15 +72,30 @@ public abstract class DocumentAutoConfigurationClasses extends DefaultTask {
|
|
|
|
|
} |
|
|
|
|
AutoConfiguration autoConfiguration = new AutoConfiguration(metadata.getProperty("module"), new TreeSet<>( |
|
|
|
|
StringUtils.commaDelimitedListToSet(metadata.getProperty("autoConfigurationClassNames")))); |
|
|
|
|
writeTable(autoConfiguration); |
|
|
|
|
writeModuleAdoc(autoConfiguration); |
|
|
|
|
} |
|
|
|
|
writeNavAdoc(autoConfigurations); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void writeTable(AutoConfiguration autoConfigurationClasses) throws IOException { |
|
|
|
|
private List<AutoConfiguration> load() { |
|
|
|
|
return this.autoConfiguration.getFiles() |
|
|
|
|
.stream() |
|
|
|
|
.map(AutoConfiguration::of) |
|
|
|
|
.sorted((a1, a2) -> a1.module.compareTo(a2.module)) |
|
|
|
|
.toList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void writeModuleAdoc(AutoConfiguration autoConfigurationClasses) { |
|
|
|
|
File outputDir = getOutputDir().getAsFile().get(); |
|
|
|
|
outputDir.mkdirs(); |
|
|
|
|
try (PrintWriter writer = new PrintWriter( |
|
|
|
|
new FileWriter(new File(outputDir, autoConfigurationClasses.module + ".adoc")))) { |
|
|
|
|
writer.println("[[appendix.auto-configuration-classes.%s]]".formatted(autoConfigurationClasses.module)); |
|
|
|
|
writer.println("= %s".formatted(autoConfigurationClasses.module)); |
|
|
|
|
writer.println(); |
|
|
|
|
writer.println("The following auto-configuration classes are from the `%s` module:" |
|
|
|
|
.formatted(autoConfigurationClasses.module)); |
|
|
|
|
writer.println(); |
|
|
|
|
writer.println("[cols=\"4,1\"]"); |
|
|
|
|
writer.println("|==="); |
|
|
|
|
writer.println("| Configuration Class | Links"); |
|
|
|
|
@ -88,6 +107,22 @@ public abstract class DocumentAutoConfigurationClasses extends DefaultTask {
@@ -88,6 +107,22 @@ public abstract class DocumentAutoConfigurationClasses extends DefaultTask {
|
|
|
|
|
} |
|
|
|
|
writer.println("|==="); |
|
|
|
|
} |
|
|
|
|
catch (IOException ex) { |
|
|
|
|
throw new UncheckedIOException(ex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void writeNavAdoc(List<AutoConfiguration> autoConfigurations) { |
|
|
|
|
File outputDir = getOutputDir().getAsFile().get(); |
|
|
|
|
outputDir.mkdirs(); |
|
|
|
|
try (PrintWriter writer = new PrintWriter(new FileWriter(new File(outputDir, "nav.adoc")))) { |
|
|
|
|
autoConfigurations.forEach((autoConfigurationClasses) -> writer |
|
|
|
|
.println("*** xref:appendix:auto-configuration-classes/%s.adoc[]" |
|
|
|
|
.formatted(autoConfigurationClasses.module))); |
|
|
|
|
} |
|
|
|
|
catch (IOException ex) { |
|
|
|
|
throw new UncheckedIOException(ex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static final class AutoConfiguration { |
|
|
|
|
@ -105,6 +140,18 @@ public abstract class DocumentAutoConfigurationClasses extends DefaultTask {
@@ -105,6 +140,18 @@ public abstract class DocumentAutoConfigurationClasses extends DefaultTask {
|
|
|
|
|
}).collect(Collectors.toCollection(TreeSet::new)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static AutoConfiguration of(File metadataFile) { |
|
|
|
|
Properties metadata = new Properties(); |
|
|
|
|
try (Reader reader = new FileReader(metadataFile)) { |
|
|
|
|
metadata.load(reader); |
|
|
|
|
} |
|
|
|
|
catch (IOException ex) { |
|
|
|
|
throw new UncheckedIOException(ex); |
|
|
|
|
} |
|
|
|
|
return new AutoConfiguration(metadata.getProperty("module"), new TreeSet<>( |
|
|
|
|
StringUtils.commaDelimitedListToSet(metadata.getProperty("autoConfigurationClassNames")))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static final class AutoConfigurationClass implements Comparable<AutoConfigurationClass> { |
|
|
|
|
|