Allow generated classes to be written directly to output directory
------------------------------------------------------------------
Key: MXMLBEANS-58
URL: http://jira.codehaus.org/browse/MXMLBEANS-58
Project: Maven 2.x Xmlbeans Plugin
Issue Type: Improvement
Affects Versions: 2.3.2
Environment: All
Reporter: Ron Gallagher
Attachments: CompileXmlBeansMojo.diff, gen-to-target-classes.tar
We have a build that uses this plugin to compile a set of schemas in 10
separate execution phases. Here's a snippet of the pom.xml file for this
project:
{code:xml}
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<executions>
<execution>
<id>xmlbeans-01</id>
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
</goals>
<configuration>
<sourceSchemas>
<snip/>
</sourceSchemas>
<sourceGenerationDirectory>${project.build.directory}/generated-sources/xmlbeans</sourceGenerationDirectory>
<staleFile>${project.build.directory}/generated-sources/xmlbeans/xmlbeans-01</staleFile>
<classGenerationDirectory>${project.build.directory}/generated-classes/xmlbeans/xmlbeans-01</classGenerationDirectory>
</configuration>
</execution>
<execution>
<id>xmlbeans-02</id>
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
</goals>
<configuration>
<sourceSchemas>
<snip/>
</sourceSchemas>
<sourceGenerationDirectory>${project.build.directory}/generated-sources/xmlbeans</sourceGenerationDirectory>
<staleFile>${project.build.directory}/generated-sources/xmlbeans/xmlbeans-02</staleFile>
<classGenerationDirectory>${project.build.directory}/generated-classes/xmlbeans/xmlbeans-02</classGenerationDirectory>
</configuration>
</execution>
<!-- above pattern repeated 8 more times. "02" replaced with "03", "04"
etc... -->
</executions>
</plugin>
{code}
I've removed the individual "sourceSchema" elements for the sake of brevity.
We are using separate stale files during each execution phase to ensure that
the schemas in each phase are only recompiled as necessary. Using one stale
file did not work.
We are also using separate 'classGenerationDirectory' values for each phase,
just to isolate the output of each invocation of XMLBeans.
The problem we are encountering is that a full run of these 10 invocations
takes over 2 hours. I have determined that 90% of this time is spent in the
updateProject method of the CompileXmlBeansMojo class. The call to
FileUtils.copyDirectoryStructure is the culprit. This method copies the
generated classes from the classGenerationDirectory to the output directory
("${project.build.outputDirectory}")for the maven project.
I tried changing the "classGenerationDirectory" settings to point to
"${project.build.outputDirectory}", but this caused the
FielUtils.copyDirectoryStructure method to throw an error:
{code:java}
// From FileUtils.copyDirectoryStructure...
if(sourceDirectory.equals(destinationDirectory)){
throw new IOException("source and destination are the same directory.");
}
{code}
Our problem would be solved if the XMLBeans plugin allowed the
"classGenerationDirectory" to point to the "${project.build.outputDirectory}"
folder. It that situation is detected, then the call to
FileUtils.copyDirectoryStructure would not be necessary.
The attached 'diff' file contains the changes that would need to be made to
org.codehaus.mojo.xmlbeans.CompileXmlBeansMojo in order to provide this
capability.
The attached tar file contains an integration test that fails without this
change but passes with the change.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email