@MojoParameter(required = false)
private String packageName;
public void execute() throws MojoExecutionException {
EJCExecutor ejc = new EJCExecutor();
try {
if(ediMappingFile.startsWith("urn:")) {
if(packageName != null) {
throw new MojoExecutionException("Invalid EJC configuration. 'packageName' must not be configured for 'urn' mapping model configurations.");
}
String urn = ediMappingFile.substring(4).trim();
String[] urnTokens;
urn = urn.replace("-", "_");
urnTokens = urn.split(":");
if(urnTokens.length != 3) {
throw new MojoExecutionException("'ediMappingFile' urn value must have a minimum of 3 colon separated tokens (4 tokens if including the leading 'urn' token).");
}
String directoryMapping = urnTokens[1];
if(directoryMapping.endsWith("_mapping")) {
directoryMapping = directoryMapping.substring(0, directoryMapping.length() - "_mapping".length());
}
packageName = urnTokens[0] + "." + directoryMapping;
} else if(packageName == null) {
throw new MojoExecutionException("Invalid EJC configuration. 'packageName' must be configured for non 'urn' mapping model configurations.");
} else {
File mappingFileObj = new File(project.getBasedir(), ediMappingFile);
if(mappingFileObj.exists()) {
ediMappingFile = mappingFileObj.toURI().toString();
}
}
ejc.setMessages(messages);
ejc.setDestDir(destDir);
ejc.setEdiMappingModel(ediMappingFile);
ejc.setPackageName(packageName);
if(destDir.exists()) {
destDir.delete();
}
ejc.execute();
project.addCompileSourceRoot(destDir.getPath());
Resource resource = new Resource();
resource.setDirectory(destDir.getPath());
resource.addInclude("**/*.xml");