use of org.l2x6.cq.maven.TemplateParams.ExtensionStatus in project cq-maven-plugin by l2x6.
the class UpdateQuarkusMetadataMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
final CqCatalog catalog = new CqCatalog(Flavor.camel);
final List<String> errors = new ArrayList<>();
findExtensions().filter(extModule -> !extModule.getArtifactIdBase().startsWith("support-")).forEach(extModule -> {
final String artifactIdBase = extModule.getArtifactIdBase();
final Path quarkusExtensionsYamlPath = extModule.getExtensionDir().resolve("runtime/src/main/resources/META-INF/quarkus-extension.yaml");
getLog().info("Regenerating " + multiModuleProjectDirectory.toPath().relativize(quarkusExtensionsYamlPath));
final List<ArtifactModel<?>> models = catalog.primaryModel(artifactIdBase);
final Model runtimePom = CqCommonUtils.readPom(extModule.getRuntimePomPath(), StandardCharsets.UTF_8);
final Path relativeRuntimePomPath = multiModuleProjectDirectory.toPath().relativize(extModule.getRuntimePomPath());
final String name = runtimePom.getName();
if (!name.endsWith(NAME_SUFFIX)) {
throw new RuntimeException("The name in " + relativeRuntimePomPath + " must end with '" + NAME_SUFFIX + "'; found: " + name);
}
final int startDelimPos = name.lastIndexOf(" :: ", name.length() - NAME_SUFFIX.length() - 1);
if (startDelimPos < 0) {
throw new RuntimeException("The name in " + relativeRuntimePomPath + " must start with '<whatever> :: '; found: " + name);
}
final String titleBase = name.substring(startDelimPos + 4, name.length() - NAME_SUFFIX.length());
final String rawKeywords = (String) runtimePom.getProperties().getProperty("quarkus.metadata.keywords");
final List<String> keywords = rawKeywords != null ? Arrays.asList(rawKeywords.split(",")) : Collections.emptyList();
final boolean unlisted = !extModule.isNativeSupported() || Boolean.parseBoolean(runtimePom.getProperties().getProperty("quarkus.metadata.unlisted", "false"));
final boolean deprecated = models.stream().anyMatch(ArtifactModel::isDeprecated) || Boolean.parseBoolean(runtimePom.getProperties().getProperty("quarkus.metadata.deprecated", "false"));
final ExtensionStatus status = ExtensionStatus.valueOf(runtimePom.getProperties().getProperty("quarkus.metadata.status", ExtensionStatus.of(extModule.isNativeSupported()).toString()));
final TemplateParams templateParams = CqUtils.quarkusExtensionYamlParams(models, artifactIdBase, titleBase, runtimePom.getDescription(), keywords, unlisted, deprecated, extModule.isNativeSupported(), status, multiModuleProjectDirectory.toPath(), getLog(), errors);
final Configuration cfg = CqUtils.getTemplateConfig(multiModuleProjectDirectory.toPath(), CqUtils.DEFAULT_TEMPLATES_URI_BASE, templatesUriBase, encoding);
CqUtils.evalTemplate(cfg, "quarkus-extension.yaml", quarkusExtensionsYamlPath, templateParams, m -> {
});
});
if (!errors.isEmpty()) {
throw new MojoFailureException(errors.stream().collect(Collectors.joining("\n")));
}
}
Aggregations