use of org.apache.camel.maven.packaging.model.OtherModel in project camel by apache.
the class PrepareReadmeMojo method generateOtherModel.
private OtherModel generateOtherModel(String json) {
List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("other", json, false);
OtherModel other = new OtherModel();
other.setName(JSonSchemaHelper.getSafeValue("name", rows));
other.setTitle(JSonSchemaHelper.getSafeValue("title", rows));
other.setDescription(JSonSchemaHelper.getSafeValue("description", rows));
other.setFirstVersion(JSonSchemaHelper.getSafeValue("firstVersion", rows));
other.setLabel(JSonSchemaHelper.getSafeValue("label", rows));
other.setDeprecated(JSonSchemaHelper.getSafeValue("deprecated", rows));
other.setGroupId(JSonSchemaHelper.getSafeValue("groupId", rows));
other.setArtifactId(JSonSchemaHelper.getSafeValue("artifactId", rows));
other.setVersion(JSonSchemaHelper.getSafeValue("version", rows));
return other;
}
use of org.apache.camel.maven.packaging.model.OtherModel in project camel by apache.
the class PrepareUserGuideMojo method executeOthers.
protected void executeOthers() throws MojoExecutionException, MojoFailureException {
Set<File> otherFiles = new TreeSet<>();
if (othersDir != null && othersDir.isDirectory()) {
File[] files = othersDir.listFiles();
if (files != null) {
otherFiles.addAll(Arrays.asList(files));
}
}
try {
List<OtherModel> models = new ArrayList<>();
for (File file : otherFiles) {
String json = loadText(new FileInputStream(file));
OtherModel model = generateOtherModel(json);
models.add(model);
}
// sor the models
Collections.sort(models, new OtherComparator());
// the summary file has the TOC
File file = new File(userGuideDir, "SUMMARY.md");
// update core components
StringBuilder other = new StringBuilder();
other.append("* Miscellaneous Components\n");
for (OtherModel model : models) {
String line = "\t* " + link(model) + "\n";
other.append(line);
}
boolean updated = updateOthers(file, other.toString());
if (updated) {
getLog().info("Updated user guide file: " + file);
} else {
getLog().debug("No changes to user guide file: " + file);
}
} catch (IOException e) {
throw new MojoFailureException("Error due " + e.getMessage(), e);
}
}
use of org.apache.camel.maven.packaging.model.OtherModel in project camel by apache.
the class PrepareUserGuideMojo method generateOtherModel.
private OtherModel generateOtherModel(String json) {
List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("other", json, false);
OtherModel other = new OtherModel();
other.setName(JSonSchemaHelper.getSafeValue("name", rows));
other.setTitle(JSonSchemaHelper.getSafeValue("title", rows));
other.setDescription(JSonSchemaHelper.getSafeValue("description", rows));
other.setFirstVersion(JSonSchemaHelper.getSafeValue("firstVersion", rows));
other.setLabel(JSonSchemaHelper.getSafeValue("label", rows));
other.setDeprecated(JSonSchemaHelper.getSafeValue("deprecated", rows));
other.setGroupId(JSonSchemaHelper.getSafeValue("groupId", rows));
other.setArtifactId(JSonSchemaHelper.getSafeValue("artifactId", rows));
other.setVersion(JSonSchemaHelper.getSafeValue("version", rows));
return other;
}
use of org.apache.camel.maven.packaging.model.OtherModel in project camel by apache.
the class PrepareReadmeMojo method executeOthersReadme.
protected void executeOthersReadme() throws MojoExecutionException, MojoFailureException {
Set<File> otherFiles = new TreeSet<>();
if (othersDir != null && othersDir.isDirectory()) {
File[] files = othersDir.listFiles();
if (files != null) {
otherFiles.addAll(Arrays.asList(files));
}
}
try {
List<OtherModel> others = new ArrayList<>();
for (File file : otherFiles) {
String json = loadText(new FileInputStream(file));
OtherModel model = generateOtherModel(json);
others.add(model);
}
// sort the models
Collections.sort(others, new OtherComparator());
// how many different artifacts
int count = others.stream().map(OtherModel::getArtifactId).collect(toSet()).size();
// how many deprecated
long deprecated = others.stream().filter(o -> "true".equals(o.getDeprecated())).count();
// update the big readme file in the components dir
File file = new File(readmeComponentsDir, "readme.adoc");
// update regular components
boolean exists = file.exists();
String changed = templateOthers(others, count, deprecated);
boolean updated = updateOthers(file, changed);
if (updated) {
getLog().info("Updated readme.adoc file: " + file);
} else if (exists) {
getLog().debug("No changes to readme.adoc file: " + file);
} else {
getLog().warn("No readme.adoc file: " + file);
}
} catch (IOException e) {
throw new MojoFailureException("Error due " + e.getMessage(), e);
}
}
Aggregations