use of org.jsonschema2pojo.AnnotatorFactory in project jsonschema2pojo by joelittlejohn.
the class Jsonschema2PojoMojo method execute.
/**
* Executes the plugin, to read the given source and behavioural properties
* and generate POJOs. The current implementation acts as a wrapper around
* the command line interface.
*/
@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = { "NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD" }, justification = "Private fields set by Maven.")
@SuppressWarnings("PMD.UselessParentheses")
public void execute() throws MojoExecutionException {
addProjectDependenciesToClasspath();
try {
getAnnotationStyle();
} catch (IllegalArgumentException e) {
throw new MojoExecutionException("Not a valid annotation style: " + annotationStyle);
}
try {
new AnnotatorFactory(this).getAnnotator(getCustomAnnotator());
} catch (IllegalArgumentException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
if (skip) {
return;
}
// verify source directories
if (sourceDirectory != null) {
sourceDirectory = FilenameUtils.normalize(sourceDirectory);
// verify sourceDirectory
try {
URLUtil.parseURL(sourceDirectory);
} catch (IllegalArgumentException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
} else if (!isEmpty(sourcePaths)) {
// verify individual source paths
for (int i = 0; i < sourcePaths.length; i++) {
sourcePaths[i] = FilenameUtils.normalize(sourcePaths[i]);
try {
URLUtil.parseURL(sourcePaths[i]);
} catch (IllegalArgumentException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
} else {
throw new MojoExecutionException("One of sourceDirectory or sourcePaths must be provided");
}
if (filteringEnabled() || (sourceDirectory != null && isEmpty(sourcePaths))) {
if (sourceDirectory == null) {
throw new MojoExecutionException("Source includes and excludes require the sourceDirectory property");
}
if (!isEmpty(sourcePaths)) {
throw new MojoExecutionException("Source includes and excludes are incompatible with the sourcePaths property");
}
fileFilter = createFileFilter();
}
if (addCompileSourceRoot) {
project.addCompileSourceRoot(outputDirectory.getPath());
}
if (useCommonsLang3) {
getLog().warn("useCommonsLang3 is deprecated. Please remove it from your config.");
}
RuleLogger logger = new MojoRuleLogger(getLog());
try {
Jsonschema2Pojo.generate(this, logger);
} catch (IOException e) {
throw new MojoExecutionException("Error generating classes from JSON Schema file(s) " + sourceDirectory, e);
}
}
Aggregations