From d329744a6d82b9f9d846ca85d4baaf4af2711177 Mon Sep 17 00:00:00 2001 From: Matheus Cruz Date: Thu, 25 Jan 2024 16:03:48 -0300 Subject: [PATCH] Fix the Quarkus Maven Pluagin documentation --- .../QuarkusMavenPluginDocsGenerator.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/src/main/java/io/quarkus/docs/generation/QuarkusMavenPluginDocsGenerator.java b/docs/src/main/java/io/quarkus/docs/generation/QuarkusMavenPluginDocsGenerator.java index 0020be0a5c902..7ef18c94898dd 100644 --- a/docs/src/main/java/io/quarkus/docs/generation/QuarkusMavenPluginDocsGenerator.java +++ b/docs/src/main/java/io/quarkus/docs/generation/QuarkusMavenPluginDocsGenerator.java @@ -5,6 +5,7 @@ import java.io.Reader; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Optional; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; @@ -82,7 +83,11 @@ public static void main(String[] args) throws Exception { final GoalParamsBuilder goalParamsBuilder = goalsConfigDocBuilder.newGoalParamsBuilder(); if (mojo.getParameters() != null) { for (Parameter parameter : mojo.getParameters()) { - goalParamsBuilder.addParam(parameter.getType(), parameter.getName(), parameter.getDefaultValue(), + String property = getPropertyFromExpression(parameter.getExpression()); + + String name = Optional.ofNullable(property).orElseGet(parameter::getName); + + goalParamsBuilder.addParam(parameter.getType(), name, parameter.getDefaultValue(), parameter.isRequired(), parameter.getDescription()); } } @@ -103,4 +108,16 @@ public static void main(String[] args) throws Exception { } } + private static String getPropertyFromExpression(String expression) { + if ((expression != null && !expression.isEmpty()) + && expression.startsWith("${") + && expression.endsWith("}") + && !expression.substring(2).contains("${")) { + // expression="${xxx}" -> property="xxx" + return expression.substring(2, expression.length() - 1); + } + // no property can be extracted + return null; + } + }