[BUILD] Auto-generate configuration properties docs (#48)
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -10,6 +10,9 @@
|
||||
.checkstyle
|
||||
bin
|
||||
build
|
||||
!/**/src/**/bin
|
||||
!/**/src/**/build
|
||||
build.log
|
||||
out
|
||||
target
|
||||
.DS_Store
|
||||
|
||||
11
build.gradle
11
build.gradle
@@ -1,11 +1,3 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven { url 'https://repo.spring.io/plugins-release' }
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'base'
|
||||
id 'project-report'
|
||||
@@ -320,6 +312,8 @@ project ('spring-pulsar') {
|
||||
project ('spring-pulsar-boot-autoconfigure') {
|
||||
description = 'Spring Boot Pulsar Autoconfiguration'
|
||||
|
||||
apply plugin: 'org.springframework.pulsar.configuration-properties'
|
||||
|
||||
dependencies {
|
||||
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor:$springBootVersion"
|
||||
|
||||
@@ -327,7 +321,6 @@ project ('spring-pulsar-boot-autoconfigure') {
|
||||
api "org.springframework.boot:spring-boot-autoconfigure:$springBootVersion"
|
||||
api "org.springframework.boot:spring-boot-starter:$springBootVersion"
|
||||
api "org.springframework.boot:spring-boot-starter-validation:$springBootVersion"
|
||||
|
||||
api project (':spring-pulsar')
|
||||
|
||||
testImplementation "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
|
||||
|
||||
49
buildSrc/build.gradle
Normal file
49
buildSrc/build.gradle
Normal file
@@ -0,0 +1,49 @@
|
||||
plugins {
|
||||
id "java-gradle-plugin"
|
||||
id "io.spring.javaformat" version "${javaFormatVersion}"
|
||||
id "checkstyle"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven { url 'https://repo.spring.io/release' }
|
||||
maven { url 'https://repo.spring.io/milestone' }
|
||||
if (version.endsWith('SNAPSHOT')) {
|
||||
maven { url 'https://repo.spring.io/snapshot' }
|
||||
}
|
||||
}
|
||||
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
|
||||
dependencies {
|
||||
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}"
|
||||
implementation(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}"))
|
||||
implementation("org.springframework:spring-core")
|
||||
implementation("org.springframework:spring-web")
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind")
|
||||
implementation("org.gradle:test-retry-gradle-plugin:${testRetryVersion}")
|
||||
implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}")
|
||||
testImplementation("org.assertj:assertj-core")
|
||||
testImplementation("org.apache.logging.log4j:log4j-core")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "${checkstyleToolVersion}"
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
configurationProperties {
|
||||
id = 'org.springframework.pulsar.configuration-properties'
|
||||
implementationClass = 'org.springframework.pulsar.build.configprops.ConfigurationPropertiesPlugin'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
9
buildSrc/config/checkstyle/checkstyle.xml
Normal file
9
buildSrc/config/checkstyle/checkstyle.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
<module name="com.puppycrawl.tools.checkstyle.Checker">
|
||||
<module name="io.spring.javaformat.checkstyle.SpringChecks">
|
||||
<property name="excludes" value="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck" />
|
||||
</module>
|
||||
</module>
|
||||
4
buildSrc/gradle.properties
Normal file
4
buildSrc/gradle.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
checkstyleToolVersion=8.11
|
||||
javaFormatVersion=0.0.34
|
||||
testRetryVersion=1.4.0
|
||||
springBootVersion=3.0.0-M4
|
||||
6
buildSrc/settings.gradle
Normal file
6
buildSrc/settings.gradle
Normal file
@@ -0,0 +1,6 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
/**
|
||||
* Simple builder to help construct Asciidoc markup.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class Asciidoc {
|
||||
|
||||
private final StringBuilder content;
|
||||
|
||||
Asciidoc() {
|
||||
this.content = new StringBuilder();
|
||||
}
|
||||
|
||||
Asciidoc appendWithHardLineBreaks(Object... items) {
|
||||
for (Object item : items) {
|
||||
appendln("`+", item, "+` +");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Asciidoc appendln(Object... items) {
|
||||
return append(items).newLine();
|
||||
}
|
||||
|
||||
Asciidoc append(Object... items) {
|
||||
for (Object item : items) {
|
||||
this.content.append(item);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Asciidoc newLine() {
|
||||
return append(System.lineSeparator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.content.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright 2012-2022 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.file.FileTree;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.tasks.InputFiles;
|
||||
import org.gradle.api.tasks.OutputFile;
|
||||
import org.gradle.api.tasks.PathSensitive;
|
||||
import org.gradle.api.tasks.PathSensitivity;
|
||||
import org.gradle.api.tasks.SourceTask;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
/**
|
||||
* {@link SourceTask} that checks additional Spring configuration metadata files.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class CheckAdditionalSpringConfigurationMetadata extends SourceTask {
|
||||
|
||||
private final RegularFileProperty reportLocation;
|
||||
|
||||
public CheckAdditionalSpringConfigurationMetadata() {
|
||||
this.reportLocation = getProject().getObjects().fileProperty();
|
||||
}
|
||||
|
||||
@OutputFile
|
||||
public RegularFileProperty getReportLocation() {
|
||||
return this.reportLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
@InputFiles
|
||||
@PathSensitive(PathSensitivity.RELATIVE)
|
||||
public FileTree getSource() {
|
||||
return super.getSource();
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void check() throws JsonParseException, IOException {
|
||||
Report report = createReport();
|
||||
File reportFile = getReportLocation().get().getAsFile();
|
||||
Files.write(reportFile.toPath(), report, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
if (report.hasProblems()) {
|
||||
throw new GradleException(
|
||||
"Problems found in additional Spring configuration metadata. See " + reportFile + " for details.");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Report createReport() throws IOException, JsonParseException, JsonMappingException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Report report = new Report();
|
||||
for (File file : getSource().getFiles()) {
|
||||
Analysis analysis = report.analysis(getProject().getProjectDir().toPath().relativize(file.toPath()));
|
||||
Map<String, Object> json = objectMapper.readValue(file, Map.class);
|
||||
check("groups", json, analysis);
|
||||
check("properties", json, analysis);
|
||||
check("hints", json, analysis);
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void check(String key, Map<String, Object> json, Analysis analysis) {
|
||||
List<Map<String, Object>> groups = (List<Map<String, Object>>) json.get(key);
|
||||
List<String> names = groups.stream().map((group) -> (String) group.get("name")).collect(Collectors.toList());
|
||||
List<String> sortedNames = sortedCopy(names);
|
||||
for (int i = 0; i < names.size(); i++) {
|
||||
String actual = names.get(i);
|
||||
String expected = sortedNames.get(i);
|
||||
if (!actual.equals(expected)) {
|
||||
analysis.problems.add("Wrong order at $." + key + "[" + i + "].name - expected '" + expected
|
||||
+ "' but found '" + actual + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> sortedCopy(Collection<String> original) {
|
||||
List<String> copy = new ArrayList<>(original);
|
||||
Collections.sort(copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static final class Report implements Iterable<String> {
|
||||
|
||||
private final List<Analysis> analyses = new ArrayList<>();
|
||||
|
||||
private Analysis analysis(Path path) {
|
||||
Analysis analysis = new Analysis(path);
|
||||
this.analyses.add(analysis);
|
||||
return analysis;
|
||||
}
|
||||
|
||||
private boolean hasProblems() {
|
||||
for (Analysis analysis : this.analyses) {
|
||||
if (!analysis.problems.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<String> iterator() {
|
||||
List<String> lines = new ArrayList<>();
|
||||
for (Analysis analysis : this.analyses) {
|
||||
lines.add(analysis.source.toString());
|
||||
lines.add("");
|
||||
if (analysis.problems.isEmpty()) {
|
||||
lines.add("No problems found.");
|
||||
}
|
||||
else {
|
||||
lines.addAll(analysis.problems);
|
||||
}
|
||||
lines.add("");
|
||||
}
|
||||
return lines.iterator();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final class Analysis {
|
||||
|
||||
private final List<String> problems = new ArrayList<>();
|
||||
|
||||
private final Path source;
|
||||
|
||||
private Analysis(Path source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Table row regrouping a list of configuration properties sharing the same description.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class CompoundRow extends Row {
|
||||
|
||||
private final Set<String> propertyNames;
|
||||
|
||||
private final String description;
|
||||
|
||||
CompoundRow(Snippet snippet, String prefix, String description) {
|
||||
super(snippet, prefix);
|
||||
this.description = description;
|
||||
this.propertyNames = new TreeSet<>();
|
||||
}
|
||||
|
||||
void addProperty(ConfigurationProperty property) {
|
||||
this.propertyNames.add(property.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
void write(Asciidoc asciidoc) {
|
||||
asciidoc.append("|");
|
||||
asciidoc.append("[[" + getAnchor() + "]]");
|
||||
asciidoc.append("<<" + getAnchor() + ",");
|
||||
this.propertyNames.forEach(asciidoc::appendWithHardLineBreaks);
|
||||
asciidoc.appendln(">>");
|
||||
asciidoc.appendln("|+++", this.description, "+++");
|
||||
asciidoc.appendln("|");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* Configuration properties read from one or more
|
||||
* {@code META-INF/spring-configuration-metadata.json} files.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
final class ConfigurationProperties {
|
||||
|
||||
private final Map<String, ConfigurationProperty> byName;
|
||||
|
||||
private ConfigurationProperties(List<ConfigurationProperty> properties) {
|
||||
Map<String, ConfigurationProperty> byName = new LinkedHashMap<>();
|
||||
for (ConfigurationProperty property : properties) {
|
||||
byName.put(property.getName(), property);
|
||||
}
|
||||
this.byName = Collections.unmodifiableMap(byName);
|
||||
}
|
||||
|
||||
ConfigurationProperty get(String propertyName) {
|
||||
return this.byName.get(propertyName);
|
||||
}
|
||||
|
||||
Stream<ConfigurationProperty> stream() {
|
||||
return this.byName.values().stream();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static ConfigurationProperties fromFiles(Iterable<File> files) {
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
List<ConfigurationProperty> properties = new ArrayList<>();
|
||||
for (File file : files) {
|
||||
Map<String, Object> json = objectMapper.readValue(file, Map.class);
|
||||
for (Map<String, Object> property : (List<Map<String, Object>>) json.get("properties")) {
|
||||
properties.add(ConfigurationProperty.fromJsonProperties(property));
|
||||
}
|
||||
}
|
||||
return new ConfigurationProperties(properties);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new RuntimeException("Failed to load configuration metadata", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright 2012-2022 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.tasks.PathSensitivity;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.TaskProvider;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.language.base.plugins.LifecycleBasePlugin;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link Plugin} for projects that define {@code @ConfigurationProperties}. When applied,
|
||||
* the plugin reacts to the presence of the {@link JavaPlugin} by:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Adding a dependency on the configuration properties annotation processor.
|
||||
* <li>Configuring the additional metadata locations annotation processor compiler
|
||||
* argument.
|
||||
* <li>Adding the outputs of the processResources task as inputs of the compileJava task
|
||||
* to ensure that the additional metadata is available when the annotation processor runs.
|
||||
* <li>Registering a {@link CheckAdditionalSpringConfigurationMetadata} task and
|
||||
* configuring the {@code check} task to depend upon it.
|
||||
* <li>Defining an artifact for the resulting configuration property metadata so that it
|
||||
* can be consumed by downstream projects.
|
||||
* </ul>
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ConfigurationPropertiesPlugin implements Plugin<Project> {
|
||||
|
||||
/**
|
||||
* Name of the {@link Configuration} that holds the configuration property metadata
|
||||
* artifact.
|
||||
*/
|
||||
public static final String CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME = "configurationPropertiesMetadata";
|
||||
|
||||
/**
|
||||
* Name of the {@link CheckAdditionalSpringConfigurationMetadata} task.
|
||||
*/
|
||||
public static final String CHECK_ADDITIONAL_SPRING_CONFIGURATION_METADATA_TASK_NAME = "checkAdditionalSpringConfigurationMetadata";
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
|
||||
// TODO addConfigurationProcessorDependency(project);
|
||||
configureAdditionalMetadataLocationsCompilerArgument(project);
|
||||
registerCheckAdditionalMetadataTask(project);
|
||||
addMetadataArtifact(project);
|
||||
});
|
||||
}
|
||||
|
||||
// private void addConfigurationProcessorDependency(Project project) {
|
||||
// Configuration annotationProcessors = project.getConfigurations()
|
||||
// .getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME);
|
||||
// annotationProcessors.getDependencies().add(project.getDependencies().project(Collections.singletonMap("path",
|
||||
// ":spring-boot-project:spring-boot-tools:spring-boot-configuration-processor")));
|
||||
// }
|
||||
|
||||
private void addMetadataArtifact(Project project) {
|
||||
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
|
||||
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
|
||||
project.getConfigurations().maybeCreate(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME);
|
||||
project.afterEvaluate((evaluatedProject) -> evaluatedProject.getArtifacts().add(
|
||||
CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME,
|
||||
mainSourceSet.getJava().getDestinationDirectory().dir("META-INF/spring-configuration-metadata.json"),
|
||||
(artifact) -> artifact
|
||||
.builtBy(evaluatedProject.getTasks().getByName(mainSourceSet.getClassesTaskName()))));
|
||||
}
|
||||
|
||||
private void configureAdditionalMetadataLocationsCompilerArgument(Project project) {
|
||||
JavaCompile compileJava = project.getTasks().withType(JavaCompile.class)
|
||||
.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME);
|
||||
((Task) compileJava).getInputs().files(project.getTasks().getByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME))
|
||||
.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("processed resources");
|
||||
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
|
||||
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
|
||||
compileJava.getOptions().getCompilerArgs()
|
||||
.add("-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations=" + StringUtils
|
||||
.collectionToCommaDelimitedString(mainSourceSet.getResources().getSourceDirectories().getFiles()
|
||||
.stream().map(project.getRootProject()::relativePath).collect(Collectors.toSet())));
|
||||
}
|
||||
|
||||
private void registerCheckAdditionalMetadataTask(Project project) {
|
||||
TaskProvider<CheckAdditionalSpringConfigurationMetadata> checkConfigurationMetadata = project.getTasks()
|
||||
.register(CHECK_ADDITIONAL_SPRING_CONFIGURATION_METADATA_TASK_NAME,
|
||||
CheckAdditionalSpringConfigurationMetadata.class);
|
||||
checkConfigurationMetadata.configure((check) -> {
|
||||
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
|
||||
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
|
||||
check.setSource(mainSourceSet.getResources());
|
||||
check.include("META-INF/additional-spring-configuration-metadata.json");
|
||||
check.getReportLocation().set(project.getLayout().getBuildDirectory()
|
||||
.file("reports/additional-spring-configuration-metadata/check.txt"));
|
||||
});
|
||||
project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME)
|
||||
.configure((check) -> check.dependsOn(checkConfigurationMetadata));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A configuration property.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class ConfigurationProperty {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String type;
|
||||
|
||||
private final Object defaultValue;
|
||||
|
||||
private final String description;
|
||||
|
||||
private final boolean deprecated;
|
||||
|
||||
ConfigurationProperty(String name, String type) {
|
||||
this(name, type, null, null, false);
|
||||
}
|
||||
|
||||
ConfigurationProperty(String name, String type, Object defaultValue, String description, boolean deprecated) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.defaultValue = defaultValue;
|
||||
this.description = description;
|
||||
this.deprecated = deprecated;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
String getDisplayName() {
|
||||
return (getType() != null && getType().startsWith("java.util.Map")) ? getName() + ".*" : getName();
|
||||
}
|
||||
|
||||
String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
Object getDefaultValue() {
|
||||
return this.defaultValue;
|
||||
}
|
||||
|
||||
String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
boolean isDeprecated() {
|
||||
return this.deprecated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConfigurationProperty [name=" + this.name + ", type=" + this.type + "]";
|
||||
}
|
||||
|
||||
static ConfigurationProperty fromJsonProperties(Map<String, Object> property) {
|
||||
String name = (String) property.get("name");
|
||||
String type = (String) property.get("type");
|
||||
Object defaultValue = property.get("defaultValue");
|
||||
String description = (String) property.get("description");
|
||||
boolean deprecated = property.containsKey("deprecated");
|
||||
return new ConfigurationProperty(name, type, defaultValue, description, deprecated);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2012-2022 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.tasks.InputFiles;
|
||||
import org.gradle.api.tasks.OutputDirectory;
|
||||
import org.gradle.api.tasks.PathSensitive;
|
||||
import org.gradle.api.tasks.PathSensitivity;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
/**
|
||||
* {@link Task} used to document auto-configuration classes.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
* @author Chris Bono
|
||||
*/
|
||||
public class DocumentConfigurationProperties extends DefaultTask {
|
||||
|
||||
private FileCollection configurationPropertyMetadata;
|
||||
|
||||
private File outputDir;
|
||||
|
||||
@InputFiles
|
||||
@PathSensitive(PathSensitivity.RELATIVE)
|
||||
public FileCollection getConfigurationPropertyMetadata() {
|
||||
return this.configurationPropertyMetadata;
|
||||
}
|
||||
|
||||
public void setConfigurationPropertyMetadata(FileCollection configurationPropertyMetadata) {
|
||||
this.configurationPropertyMetadata = configurationPropertyMetadata;
|
||||
}
|
||||
|
||||
@OutputDirectory
|
||||
public File getOutputDir() {
|
||||
return this.outputDir;
|
||||
}
|
||||
|
||||
public void setOutputDir(File outputDir) {
|
||||
this.outputDir = outputDir;
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void documentConfigurationProperties() throws IOException {
|
||||
Snippets snippets = new Snippets(this.configurationPropertyMetadata);
|
||||
snippets.add("application-properties.pulsar", "Pulsar Properties", this::pulsarPrefixes);
|
||||
snippets.writeTo(this.outputDir.toPath());
|
||||
}
|
||||
|
||||
private void pulsarPrefixes(Snippet.Config config) {
|
||||
config.accept("spring.pulsar");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
/**
|
||||
* Abstract class for rows in {@link Table}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
abstract class Row implements Comparable<Row> {
|
||||
|
||||
private final Snippet snippet;
|
||||
|
||||
private final String id;
|
||||
|
||||
protected Row(Snippet snippet, String id) {
|
||||
this.snippet = snippet;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Row other = (Row) obj;
|
||||
return this.id.equals(other.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Row other) {
|
||||
return this.id.compareTo(other.id);
|
||||
}
|
||||
|
||||
String getAnchor() {
|
||||
return this.snippet.getAnchor() + "." + this.id;
|
||||
}
|
||||
|
||||
abstract void write(Asciidoc asciidoc);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Table row containing a single configuration property.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class SingleRow extends Row {
|
||||
|
||||
private final String displayName;
|
||||
|
||||
private final String description;
|
||||
|
||||
private final String defaultValue;
|
||||
|
||||
SingleRow(Snippet snippet, ConfigurationProperty property) {
|
||||
super(snippet, property.getName());
|
||||
this.displayName = property.getDisplayName();
|
||||
this.description = property.getDescription();
|
||||
this.defaultValue = getDefaultValue(property.getDefaultValue());
|
||||
}
|
||||
|
||||
private String getDefaultValue(Object defaultValue) {
|
||||
if (defaultValue == null) {
|
||||
return null;
|
||||
}
|
||||
if (defaultValue.getClass().isArray()) {
|
||||
return Arrays.stream((Object[]) defaultValue).map(Object::toString)
|
||||
.collect(Collectors.joining("," + System.lineSeparator()));
|
||||
}
|
||||
return defaultValue.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
void write(Asciidoc asciidoc) {
|
||||
asciidoc.append("|");
|
||||
asciidoc.append("[[" + getAnchor() + "]]");
|
||||
asciidoc.appendln("<<" + getAnchor() + ",`+", this.displayName, "+`>>");
|
||||
writeDescription(asciidoc);
|
||||
writeDefaultValue(asciidoc);
|
||||
}
|
||||
|
||||
private void writeDescription(Asciidoc builder) {
|
||||
if (this.description == null || this.description.isEmpty()) {
|
||||
builder.appendln("|");
|
||||
}
|
||||
else {
|
||||
String cleanedDescription = this.description.replace("|", "\\|").replace("<", "<").replace(">", ">");
|
||||
builder.appendln("|+++", cleanedDescription, "+++");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeDefaultValue(Asciidoc builder) {
|
||||
String defaultValue = (this.defaultValue != null) ? this.defaultValue : "";
|
||||
if (defaultValue.isEmpty()) {
|
||||
builder.appendln("|");
|
||||
}
|
||||
else {
|
||||
defaultValue = defaultValue.replace("\\", "\\\\").replace("|", "\\|");
|
||||
builder.appendln("|`+", defaultValue, "+`");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* A configuration properties snippet.
|
||||
*
|
||||
* @author Brian Clozed
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class Snippet {
|
||||
|
||||
private final String anchor;
|
||||
|
||||
private final String title;
|
||||
|
||||
private final Set<String> prefixes;
|
||||
|
||||
private final Map<String, String> overrides;
|
||||
|
||||
Snippet(String anchor, String title, Consumer<Config> config) {
|
||||
Set<String> prefixes = new LinkedHashSet<>();
|
||||
Map<String, String> overrides = new LinkedHashMap<>();
|
||||
if (config != null) {
|
||||
config.accept(new Config() {
|
||||
|
||||
@Override
|
||||
public void accept(String prefix) {
|
||||
prefixes.add(prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(String prefix, String description) {
|
||||
overrides.put(prefix, description);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
this.anchor = anchor;
|
||||
this.title = title;
|
||||
this.prefixes = prefixes;
|
||||
this.overrides = overrides;
|
||||
}
|
||||
|
||||
String getAnchor() {
|
||||
return this.anchor;
|
||||
}
|
||||
|
||||
String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
void forEachPrefix(Consumer<String> action) {
|
||||
this.prefixes.forEach(action);
|
||||
}
|
||||
|
||||
void forEachOverride(BiConsumer<String, String> action) {
|
||||
this.overrides.forEach(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to configure the snippet.
|
||||
*/
|
||||
interface Config {
|
||||
|
||||
/**
|
||||
* Accept the given prefix using the meta-data description.
|
||||
* @param prefix the prefix to accept
|
||||
*/
|
||||
void accept(String prefix);
|
||||
|
||||
/**
|
||||
* Accept the given prefix with a defined description.
|
||||
* @param prefix the prefix to accept
|
||||
* @param description the description to use
|
||||
*/
|
||||
void accept(String prefix, String description);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright 2012-2022 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.gradle.api.file.FileCollection;
|
||||
|
||||
/**
|
||||
* Configuration properties snippets.
|
||||
*
|
||||
* @author Brian Clozed
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class Snippets {
|
||||
|
||||
private final ConfigurationProperties properties;
|
||||
|
||||
private final List<Snippet> snippets = new ArrayList<>();
|
||||
|
||||
Snippets(FileCollection configurationPropertyMetadata) {
|
||||
this.properties = ConfigurationProperties.fromFiles(configurationPropertyMetadata);
|
||||
}
|
||||
|
||||
void add(String anchor, String title, Consumer<Snippet.Config> config) {
|
||||
this.snippets.add(new Snippet(anchor, title, config));
|
||||
}
|
||||
|
||||
void writeTo(Path outputDirectory) throws IOException {
|
||||
createDirectory(outputDirectory);
|
||||
Set<String> remaining = this.properties.stream().filter((property) -> !property.isDeprecated())
|
||||
.map(ConfigurationProperty::getName).collect(Collectors.toSet());
|
||||
for (Snippet snippet : this.snippets) {
|
||||
Set<String> written = writeSnippet(outputDirectory, snippet, remaining);
|
||||
remaining.removeAll(written);
|
||||
}
|
||||
if (!remaining.isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
"The following keys were not written to the documentation: " + String.join(", ", remaining));
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> writeSnippet(Path outputDirectory, Snippet snippet, Set<String> remaining) throws IOException {
|
||||
Table table = new Table();
|
||||
Set<String> added = new HashSet<>();
|
||||
snippet.forEachOverride((prefix, description) -> {
|
||||
CompoundRow row = new CompoundRow(snippet, prefix, description);
|
||||
remaining.stream().filter((candidate) -> candidate.startsWith(prefix)).forEach((name) -> {
|
||||
if (added.add(name)) {
|
||||
row.addProperty(this.properties.get(name));
|
||||
}
|
||||
});
|
||||
table.addRow(row);
|
||||
});
|
||||
snippet.forEachPrefix((prefix) -> {
|
||||
remaining.stream().filter((candidate) -> candidate.startsWith(prefix)).forEach((name) -> {
|
||||
if (added.add(name)) {
|
||||
table.addRow(new SingleRow(snippet, this.properties.get(name)));
|
||||
}
|
||||
});
|
||||
});
|
||||
Asciidoc asciidoc = getAsciidoc(snippet, table);
|
||||
writeAsciidoc(outputDirectory, snippet, asciidoc);
|
||||
return added;
|
||||
}
|
||||
|
||||
private Asciidoc getAsciidoc(Snippet snippet, Table table) {
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
// We have to prepend 'appendix.' as a section id here, otherwise the
|
||||
// spring-asciidoctor-extensions:section-id asciidoctor extension complains
|
||||
asciidoc.appendln("[[appendix." + snippet.getAnchor() + "]]");
|
||||
asciidoc.appendln("== ", snippet.getTitle());
|
||||
table.write(asciidoc);
|
||||
return asciidoc;
|
||||
}
|
||||
|
||||
private void writeAsciidoc(Path outputDirectory, Snippet snippet, Asciidoc asciidoc) throws IOException {
|
||||
String[] parts = (snippet.getAnchor()).split("\\.");
|
||||
Path path = outputDirectory;
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
String name = (i < parts.length - 1) ? parts[i] : parts[i] + ".adoc";
|
||||
path = path.resolve(name);
|
||||
}
|
||||
createDirectory(path.getParent());
|
||||
Files.deleteIfExists(path);
|
||||
try (OutputStream outputStream = Files.newOutputStream(path)) {
|
||||
outputStream.write(asciidoc.toString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
private void createDirectory(Path path) throws IOException {
|
||||
assertValidOutputDirectory(path);
|
||||
if (!Files.exists(path)) {
|
||||
Files.createDirectory(path);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertValidOutputDirectory(Path path) {
|
||||
if (path == null) {
|
||||
throw new IllegalArgumentException("Directory path should not be null");
|
||||
}
|
||||
if (Files.exists(path) && !Files.isDirectory(path)) {
|
||||
throw new IllegalArgumentException("Path already exists and is not a directory");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Asciidoctor table listing configuration properties sharing to a common theme.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
class Table {
|
||||
|
||||
private final Set<Row> rows = new TreeSet<>();
|
||||
|
||||
void addRow(Row row) {
|
||||
this.rows.add(row);
|
||||
}
|
||||
|
||||
void write(Asciidoc asciidoc) {
|
||||
asciidoc.appendln("[cols=\"4,3,3\", options=\"header\"]");
|
||||
asciidoc.appendln("|===");
|
||||
asciidoc.appendln("|Name|Description|Default Value");
|
||||
asciidoc.appendln();
|
||||
this.rows.forEach((entry) -> {
|
||||
entry.write(asciidoc);
|
||||
asciidoc.appendln();
|
||||
});
|
||||
asciidoc.appendln("|===");
|
||||
}
|
||||
|
||||
}
|
||||
202
buildSrc/src/main/resources/LICENSE.txt
Normal file
202
buildSrc/src/main/resources/LICENSE.txt
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
https://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
6
buildSrc/src/main/resources/NOTICE.txt
Normal file
6
buildSrc/src/main/resources/NOTICE.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
Spring Pulsar ${version}
|
||||
Copyright (c) 2022-2022 Pivotal, Inc.
|
||||
|
||||
This product is licensed to you under the Apache License, Version 2.0
|
||||
(the "License"). You may not use this product except in compliance with
|
||||
the License.
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link CompoundRow}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
class CompoundRowTests {
|
||||
|
||||
private static final String NEWLINE = System.lineSeparator();
|
||||
|
||||
private static final Snippet SNIPPET = new Snippet("my", "title", null);
|
||||
|
||||
@Test
|
||||
void simpleProperty() {
|
||||
CompoundRow row = new CompoundRow(SNIPPET, "spring.test", "This is a description.");
|
||||
row.addProperty(new ConfigurationProperty("spring.test.first", "java.lang.String"));
|
||||
row.addProperty(new ConfigurationProperty("spring.test.second", "java.lang.String"));
|
||||
row.addProperty(new ConfigurationProperty("spring.test.third", "java.lang.String"));
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test]]<<my.spring.test,`+spring.test.first+` +"
|
||||
+ NEWLINE + "`+spring.test.second+` +" + NEWLINE + "`+spring.test.third+` +" + NEWLINE + ">>" + NEWLINE
|
||||
+ "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConfigurationProperties}
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class ConfigurationPropertiesTests {
|
||||
|
||||
@Test
|
||||
void whenJsonHasAnIntegerDefaultValueThenItRemainsAnIntegerWhenRead() {
|
||||
ConfigurationProperties properties = ConfigurationProperties
|
||||
.fromFiles(Arrays.asList(new File("src/test/resources/spring-configuration-metadata.json")));
|
||||
assertThat(properties.get("example.counter").getDefaultValue()).isEqualTo(0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link SingleRow}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
class SingleRowTests {
|
||||
|
||||
private static final String NEWLINE = System.lineSeparator();
|
||||
|
||||
private static final Snippet SNIPPET = new Snippet("my", "title", null);
|
||||
|
||||
@Test
|
||||
void simpleProperty() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop", "java.lang.String", "something",
|
||||
"This is a description.", false);
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+something+`" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void noDefaultValue() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop", "java.lang.String", null,
|
||||
"This is a description.", false);
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultValueWithPipes() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop", "java.lang.String",
|
||||
"first|second", "This is a description.", false);
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first\\|second+`" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultValueWithBackslash() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop", "java.lang.String",
|
||||
"first\\second", "This is a description.", false);
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first\\\\second+`" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void descriptionWithPipe() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop", "java.lang.String", null,
|
||||
"This is a description with a | pipe.", false);
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|+++This is a description with a \\| pipe.+++" + NEWLINE + "|" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapProperty() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop",
|
||||
"java.util.Map<java.lang.String,java.lang.String>", null, "This is a description.", false);
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc.toString())
|
||||
.isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop.*+`>>" + NEWLINE
|
||||
+ "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void listProperty() {
|
||||
String[] defaultValue = new String[] { "first", "second", "third" };
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop",
|
||||
"java.util.List<java.lang.String>", defaultValue, "This is a description.", false);
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc.toString()).isEqualTo("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first," + NEWLINE + "second," + NEWLINE
|
||||
+ "third+`" + NEWLINE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.build.configprops;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link Table}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
class TableTests {
|
||||
|
||||
private static final String NEWLINE = System.lineSeparator();
|
||||
|
||||
private static final Snippet SNIPPET = new Snippet("my", "title", null);
|
||||
|
||||
@Test
|
||||
void simpleTable() {
|
||||
Table table = new Table();
|
||||
table.addRow(new SingleRow(SNIPPET, new ConfigurationProperty("spring.test.prop", "java.lang.String",
|
||||
"something", "This is a description.", false)));
|
||||
table.addRow(new SingleRow(SNIPPET, new ConfigurationProperty("spring.test.other", "java.lang.String",
|
||||
"other value", "This is another description.", false)));
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
table.write(asciidoc);
|
||||
// @formatter:off
|
||||
assertThat(asciidoc.toString()).isEqualTo(
|
||||
"[cols=\"4,3,3\", options=\"header\"]" + NEWLINE +
|
||||
"|===" + NEWLINE +
|
||||
"|Name|Description|Default Value" + NEWLINE + NEWLINE +
|
||||
"|[[my.spring.test.other]]<<my.spring.test.other,`+spring.test.other+`>>" + NEWLINE +
|
||||
"|+++This is another description.+++" + NEWLINE +
|
||||
"|`+other value+`" + NEWLINE + NEWLINE +
|
||||
"|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>" + NEWLINE +
|
||||
"|+++This is a description.+++" + NEWLINE +
|
||||
"|`+something+`" + NEWLINE + NEWLINE +
|
||||
"|===" + NEWLINE);
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"properties": [
|
||||
{
|
||||
"name": "example.counter",
|
||||
"type": "java.lang.Integer",
|
||||
"defaultValue": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import org.springframework.pulsar.build.configprops.DocumentConfigurationProperties
|
||||
|
||||
plugins {
|
||||
id 'org.asciidoctor.jvm.pdf' version '3.3.2'
|
||||
id 'org.asciidoctor.jvm.gems' version '3.3.2'
|
||||
@@ -15,6 +17,7 @@ ext {
|
||||
|
||||
configurations {
|
||||
asciidoctorExt
|
||||
configurationProperties
|
||||
docs
|
||||
}
|
||||
|
||||
@@ -22,6 +25,7 @@ dependencies {
|
||||
api "org.springframework.boot:spring-boot-starter:$springBootVersion"
|
||||
api project (':spring-pulsar')
|
||||
asciidoctorExt "io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch:$blockSwitchVersion"
|
||||
configurationProperties(project(path: ":spring-pulsar-boot-autoconfigure", configuration: "configurationPropertiesMetadata"))
|
||||
docs "io.spring.docresources:spring-doc-resources:${docResourcesVersion}@zip"
|
||||
}
|
||||
|
||||
@@ -74,8 +78,8 @@ task aggregatedJavadoc(type: Javadoc) {
|
||||
docTitle = "Spring Pulsar ${project.version} API"
|
||||
windowTitle = "Spring Pulsar ${project.version} API"
|
||||
overview = 'src/api/overview.html'
|
||||
memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
|
||||
outputLevel = org.gradle.external.javadoc.JavadocOutputLevel.QUIET
|
||||
memberLevel = JavadocMemberLevel.PROTECTED
|
||||
outputLevel = JavadocOutputLevel.QUIET
|
||||
splitIndex = true
|
||||
use = true
|
||||
addBooleanOption('Xdoclint:syntax', true) // only check syntax with doclint
|
||||
@@ -87,13 +91,22 @@ task aggregatedJavadoc(type: Javadoc) {
|
||||
}
|
||||
}
|
||||
|
||||
task prepareAsciidocBuild(type: Sync, dependsOn: configurations.docs) {
|
||||
task documentConfigurationProperties(type: DocumentConfigurationProperties) {
|
||||
configurationPropertyMetadata = configurations.configurationProperties
|
||||
outputDir = file("${buildDir}/docs/generated/")
|
||||
}
|
||||
|
||||
task prepareAsciidocBuild(type: Sync, dependsOn: [configurations.docs, documentConfigurationProperties]) {
|
||||
from {
|
||||
configurations.docs.collect { zipTree(it) }
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
|
||||
from 'src/main/asciidoc/'
|
||||
into "$buildDir/asciidoc"
|
||||
|
||||
from "$buildDir/docs/generated"
|
||||
into "$buildDir/asciidoc"
|
||||
}
|
||||
|
||||
asciidoctorPdf {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
[appendix]
|
||||
[[appendix.application-properties]]
|
||||
= Application Properties
|
||||
|
||||
Various properties can be specified inside your `application.properties` file, inside your `application.yml` file, or as command line switches.
|
||||
This appendix provides a list of Spring Pulsar properties and references to the underlying classes that consume them.
|
||||
|
||||
TIP: Spring Boot provides various conversion mechanism with advanced value formatting, make sure to review <<features#features.external-config.typesafe-configuration-properties.conversion, the properties conversion section>>.
|
||||
|
||||
NOTE: Property contributions can come from additional jar files on your classpath, so you should not consider this an exhaustive list.
|
||||
Also, you can define your own properties.
|
||||
|
||||
include::application-properties/pulsar.adoc[]
|
||||
@@ -590,3 +590,9 @@ public void listen(Foo foo) {
|
||||
```
|
||||
|
||||
On the producer side also, for the Java primitive types, the framework can infer the Schema, but for any other types, you need set that on the `PulsarTemmplate`.
|
||||
|
||||
=== Appendix
|
||||
The reference documentation has the following appendices:
|
||||
|
||||
[horizontal]
|
||||
<<application-properties#appendix.application-properties,Application Properties>> :: Application properties that you can use to configure your Pulsar application.
|
||||
|
||||
Reference in New Issue
Block a user