in maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java [146:238]
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().debug( " ======= XBeanMojo settings =======" );
getLog().debug( "namespace[" + namespace + "]" );
getLog().debug( "srcDir[" + srcDir + "]" );
getLog().debug( "schema[" + schema + "]" );
getLog().debug( "excludedClasses[" + excludedClasses + "]");
getLog().debug( "outputDir[" + outputDir + "]" );
getLog().debug( "propertyEditorPaths[" + propertyEditorPaths + "]" );
getLog().debug( "schemaAsArtifact[" + schemaAsArtifact + "]");
getLog().debug( "generateSpringSchemasFile[" + generateSpringSchemasFile + "]");
getLog().debug( "generateSpringHandlersFile[" + generateSpringHandlersFile + "]");
if (schema == null) {
schema = new File(outputDir, project.getArtifactId() + ".xsd");
}
if (propertyEditorPaths != null) {
List<String> editorSearchPath = new LinkedList<String>(Arrays.asList(PropertyEditorManager.getEditorSearchPath()));
for (StringTokenizer paths = new StringTokenizer(propertyEditorPaths, " ,"); paths.hasMoreElements(); ) {
//StringTokenizer implements Enumeration<Object>, not Enumeration<String> !!
editorSearchPath.add((String) paths.nextElement());
}
PropertyEditorManager.setEditorSearchPath( editorSearchPath.toArray(new String[editorSearchPath.size()]));
}
ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
schema.getParentFile().mkdirs();
String[] excludedClasses = null;
if (this.excludedClasses != null) {
excludedClasses = this.excludedClasses.split(" *, *");
}
Set<Artifact> dependencies = project.getDependencyArtifacts();
List<File> sourceJars = new ArrayList<File>();
sourceJars.add(srcDir);
if( includes !=null ) {
for (String src : includes) {
sourceJars.add(new File(src));
}
}
for (Artifact dependency : dependencies) {
if ("sources".equals(dependency.getClassifier())) {
File file = dependency.getFile();
sourceJars.add(file);
}
}
File[] srcJars = sourceJars.toArray(new File[sourceJars.size()]);
MappingLoader mappingLoader = new QdoxMappingLoader(namespace, srcJars, excludedClasses);
GeneratorPlugin[] plugins = new GeneratorPlugin[]{
new XmlMetadataGenerator(outputDir.getAbsolutePath(), schema, generateSpringSchemasFile, generateSpringHandlersFile),
new DocumentationGenerator(schema),
new XsdGenerator(schema, strictXsdOrder),
new WikiDocumentationGenerator(schema),
};
// load the mappings
Thread.currentThread().setContextClassLoader(getClassLoader());
Set<NamespaceMapping> namespaces = mappingLoader.loadNamespaces();
if (namespaces.isEmpty()) {
System.out.println("Warning: no namespaces found!");
}
// generate the files
for (NamespaceMapping namespaceMapping : namespaces) {
for (GeneratorPlugin plugin : plugins) {
plugin.setLog(this);
plugin.generate(namespaceMapping);
}
for (GeneratorPlugin plugin : generatorPlugins) {
plugin.setLog(this);
plugin.generate(namespaceMapping);
}
}
// Attach them as artifacts
if (schemaAsArtifact) {
projectHelper.attachArtifact(project, "xsd", null, schema);
projectHelper.attachArtifact(project, "html", "schema", new File(schema.getAbsolutePath() + ".html"));
}
Resource res = new Resource();
res.setDirectory(outputDir.toString());
project.addResource(res);
log("...done.");
} catch (Exception e) {
throw new BuildException(e);
} finally {
Thread.currentThread().setContextClassLoader(oldCL);
}
}