use of com.devonfw.cobigen.api.to.GenerableArtifact in project cobigen by devonfw.
the class GenerateMojo method collectTemplates.
/**
* Generates all templates for each input.
*
* @param cobiGen generator instance to be used for generation
* @param inputs to be used for generation
* @return the collected templates to be generated
* @throws MojoFailureException if any problem occurred while generation
*/
private List<GenerableArtifact> collectTemplates(CobiGen cobiGen, List<Object> inputs) throws MojoFailureException {
List<GenerableArtifact> generableArtifacts = new ArrayList<>();
if (this.templates != null && !this.templates.isEmpty()) {
if (this.templates.contains(ALL)) {
if (this.templates.size() > 1) {
throw new MojoFailureException("You specified the 'ALL' template to generate all available templates next to another template, which was most probably not intended.");
}
for (Object input : inputs) {
generableArtifacts.addAll(cobiGen.getMatchingTemplates(input));
}
} else {
for (Object input : inputs) {
List<TemplateTo> matchingTemplates = cobiGen.getMatchingTemplates(input);
List<String> configuredTemplates = new LinkedList<>(this.templates);
for (TemplateTo template : matchingTemplates) {
if (this.templates.contains(template.getId())) {
generableArtifacts.add(template);
configuredTemplates.remove(template.getId());
}
}
// error handling for increments not found
if (!configuredTemplates.isEmpty()) {
throw new MojoFailureException("Templates with ids '" + configuredTemplates + "' did not match package in folder '" + getStringRepresentation(input) + "'.");
}
}
}
}
return generableArtifacts;
}
Aggregations