Skip to content

Commit

Permalink
Merge pull request quarkusio#37920 from mcruzdev/issue-37488
Browse files Browse the repository at this point in the history
Fixes create and update goals docs
  • Loading branch information
ia3andy authored Jan 25, 2024
2 parents f418d11 + d329744 commit 52292c7
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}
Expand All @@ -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;
}

}

0 comments on commit 52292c7

Please sign in to comment.