Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public final class Outputs {
public static final String META_INF_QUARKUS_CONFIG = "META-INF/" + QUARKUS_CONFIG_DOC;
public static final String META_INF_QUARKUS_CONFIG_JAVADOC_JSON = META_INF_QUARKUS_CONFIG + "/quarkus-config-javadoc.json";
public static final String META_INF_QUARKUS_CONFIG_MODEL_JSON = META_INF_QUARKUS_CONFIG + "/quarkus-config-model.json";
public static final String META_INF_QUARKUS_CONFIG_JAVADOC_YAML = META_INF_QUARKUS_CONFIG + "/quarkus-config-javadoc.yaml";
public static final String META_INF_QUARKUS_CONFIG_MODEL_YAML = META_INF_QUARKUS_CONFIG + "/quarkus-config-model.yaml";
public static final String META_INF_QUARKUS_CONFIG_MODEL_VERSION = META_INF_QUARKUS_CONFIG
+ "/quarkus-config-model-version";

/**
* Ideally, we should remove this file at some point.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ private Optional<TypeElement> findAnnotation(Set<? extends TypeElement> annotati
public void finalizeProcessing() {
ConfigCollector configCollector = configAnnotationScanner.finalizeProcessing();

// TODO radcortez drop this once we don't need them anymore
// we will still need to read the quarkus-javadoc.properties in the Dev UI for now to allow for extensions built with older Quarkus versions
Properties javadocProperties = new Properties();
for (Entry<String, JavadocElement> javadocElementEntry : configCollector.getJavadocElements().entrySet()) {
if (javadocElementEntry.getValue().description() == null
Expand All @@ -84,12 +86,12 @@ public void finalizeProcessing() {

// the model is not written in the jar file
JavadocElements javadocElements = configResolver.resolveJavadoc();
if (!javadocElements.elements().isEmpty()) {
if (!javadocElements.isEmpty()) {
utils.filer().writeModel(Outputs.QUARKUS_CONFIG_DOC_JAVADOC, javadocElements);
}

ResolvedModel resolvedModel = configResolver.resolveModel();
if (!resolvedModel.getConfigRoots().isEmpty()) {
if (!resolvedModel.isEmpty()) {
Path resolvedModelPath = utils.filer().writeModel(Outputs.QUARKUS_CONFIG_DOC_MODEL, resolvedModel);

if (config.isDebug()) {
Expand All @@ -101,5 +103,17 @@ public void finalizeProcessing() {
}
}
}

// Generate files that will be stored in the jar and can be consumed freely.
// We generate JSON files to avoid requiring an additional dependency to the YAML mapper
if (!javadocElements.isEmpty()) {
utils.filer().writeJson(Outputs.META_INF_QUARKUS_CONFIG_JAVADOC_JSON, javadocElements);
}
if (!resolvedModel.isEmpty()) {
utils.filer().writeJson(Outputs.META_INF_QUARKUS_CONFIG_MODEL_JSON, resolvedModel);
}
if (!javadocElements.isEmpty() || !resolvedModel.isEmpty()) {
utils.filer().write(Outputs.META_INF_QUARKUS_CONFIG_MODEL_VERSION, "1");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ public class FilerUtil {
this.processingEnv = processingEnv;
}

/**
* This method uses the annotation processor Filer API and we shouldn't use a Path as paths containing \ are not supported.
*/
public void write(String filePath, String value) {
if (value == null || value.isBlank()) {
return;
}

try {
final FileObject listResource = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "",
filePath);

try (BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(listResource.openOutputStream(), StandardCharsets.UTF_8))) {
writer.write(value);
}
} catch (IOException e) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Failed to write " + filePath + ": " + e);
return;
}
}

/**
* This method uses the annotation processor Filer API and we shouldn't use a Path as paths containing \ are not supported.
*/
Expand All @@ -44,7 +66,7 @@ public void write(String filePath, Set<String> set) {

try {
final FileObject listResource = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "",
filePath.toString());
filePath);

try (BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(listResource.openOutputStream(), StandardCharsets.UTF_8))) {
Expand All @@ -69,7 +91,7 @@ public void write(String filePath, Properties properties) {

try {
final FileObject propertiesResource = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "",
filePath.toString());
filePath);

try (BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(propertiesResource.openOutputStream(), StandardCharsets.UTF_8))) {
Expand All @@ -91,7 +113,7 @@ public void writeJson(String filePath, Object value) {

try {
final FileObject jsonResource = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "",
filePath.toString());
filePath);

try (OutputStream os = jsonResource.openOutputStream()) {
JacksonMappers.jsonObjectWriter().writeValue(os, value);
Expand All @@ -112,7 +134,7 @@ public void writeYaml(String filePath, Object value) {

try {
final FileObject yamlResource = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "",
filePath.toString());
filePath);

try (OutputStream os = yamlResource.openOutputStream()) {
JacksonMappers.yamlObjectWriter().writeValue(os, value);
Expand Down
Loading