Issue with Maven's JAXB2 plugin

View: New views
4 Messages — Rating Filter:   Alert me  

Issue with Maven's JAXB2 plugin

by Tahmasebi, Hamid Reza :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 
I'm running into an issue with Maven's JAXB2 plugin. I have 2 different schemas (aaaaTestCaseSchema.xsd and bbbbTestCaseSchema.xsd) and want 2 different packages (com.tmp.aaaa.dataDrivenTests and com.tmp.bbbb.dataDrivenTests) for those schemas. I followed the recommendation in plugin's FAQ page (http://mojo.codehaus.org/jaxb2-maven-plugin/faq.html <https://owa.ku.edu/exchweb/bin/redir.asp?URL=http://mojo.codehaus.org/jaxb2-maven-plugin/faq.html> ) and created 2 executions in JAXB2 plugin declaration with each execution having its own configuration declaration. In each configuration I specified the schema and package to be run for that execution. The problem is that the last execution always overwrites the first generated files, i.e., the plugin generates com.tmp.aaaa.dataDrivenTests package and its associated java files underneath this package and then overwrites it with com.tmp.bbbb.dataDrivenTests package and its java files when it runs the second execution. Here is my plugin declaration in pom.xml:
 
 
<plugins>
<plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>jaxb2-maven-plugin</artifactId>
 <version>1.2</version>
 <executions>
  <execution>
   <id>da</id>
   <phase>test</phase>
   <goals>
    <goal>xjc</goal>
   </goals>
   <configuration>
    <schemaDirectory>./src/test/resources</schemaDirectory>
    <schemaFiles>aaaaTestCaseSchema.xsd</schemaFiles>
    <removeOldOutput>true</removeOldOutput>
    <generateDirectory>./src/test/java</generateDirectory>
    <packageName>com.tmp.aaaa.dataDrivenTests</packageName>
    <staleFile>${project.build.directory}/generated-sources/jaxb/.staleFlagAaaa</staleFile>
   </configuration>
  </execution>
  <execution>
   <id>scims</id>
   <phase>test</phase>
   <goals>
    <goal>xjc</goal>
   </goals>
   <configuration>
    <schemaDirectory>./src/test/resources</schemaDirectory>
    <schemaFiles>bbbbTestCaseSchema.xsd</schemaFiles>
    <removeOldOutput>true</removeOldOutput>
    <generateDirectory>./src/test/java</generateDirectory>
    <packageName>com.tmp.bbbb.dataDrivenTests</packageName>
    <staleFile>${project.build.directory}/generated-sources/jaxb/.staleFlagBbbb</staleFile>
   </configuration>
  </execution>
 </executions>

</plugin>
 
Any idea as what I'm doing wrong?

Thanks

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Issue with Maven's JAXB2 plugin

by Stephen Connolly-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

have a look at

https://svn.dev.java.net/vcc/trunk/vcc/thirdparty/vi-api/pom.xml

should show you how

[anonymous checkout from java.net is username: guest empty password]

Sent from my [rhymes with myPod] ;-)

On 3 Sep 2009, at 20:53, "Tahmasebi, Hamid Reza" <htahmase@...>  
wrote:

> Hi,
>
> I'm running into an issue with Maven's JAXB2 plugin. I have 2  
> different schemas (aaaaTestCaseSchema.xsd and  
> bbbbTestCaseSchema.xsd) and want 2 different packages  
> (com.tmp.aaaa.dataDrivenTests and com.tmp.bbbb.dataDrivenTests) for  
> those schemas. I followed the recommendation in plugin's FAQ page (http://mojo.codehaus.org/jaxb2-maven-plugin/faq.html 
>  <https://owa.ku.edu/exchweb/bin/redir.asp?URL=http://mojo.codehaus.org/jaxb2-maven-plugin/faq.html 
> > ) and created 2 executions in JAXB2 plugin declaration with each  
> execution having its own configuration declaration. In each  
> configuration I specified the schema and package to be run for that  
> execution. The problem is that the last execution always overwrites  
> the first generated files, i.e., the plugin generates  
> com.tmp.aaaa.dataDrivenTests package and its associated java files  
> underneath this package and then overwrites it with  
> com.tmp.bbbb.dataDrivenTests package and its java files when it runs  
> the second execution. Here is my plugin declaration in pom.xml:
>
>
> <plugins>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>jaxb2-maven-plugin</artifactId>
> <version>1.2</version>
> <executions>
>  <execution>
>   <id>da</id>
>   <phase>test</phase>
>   <goals>
>    <goal>xjc</goal>
>   </goals>
>   <configuration>
>    <schemaDirectory>./src/test/resources</schemaDirectory>
>    <schemaFiles>aaaaTestCaseSchema.xsd</schemaFiles>
>    <removeOldOutput>true</removeOldOutput>
>    <generateDirectory>./src/test/java</generateDirectory>
>    <packageName>com.tmp.aaaa.dataDrivenTests</packageName>
>    <staleFile>${project.build.directory}/generated-sources/
> jaxb/.staleFlagAaaa</staleFile>
>   </configuration>
>  </execution>
>  <execution>
>   <id>scims</id>
>   <phase>test</phase>
>   <goals>
>    <goal>xjc</goal>
>   </goals>
>   <configuration>
>    <schemaDirectory>./src/test/resources</schemaDirectory>
>    <schemaFiles>bbbbTestCaseSchema.xsd</schemaFiles>
>    <removeOldOutput>true</removeOldOutput>
>    <generateDirectory>./src/test/java</generateDirectory>
>    <packageName>com.tmp.bbbb.dataDrivenTests</packageName>
>    <staleFile>${project.build.directory}/generated-sources/
> jaxb/.staleFlagBbbb</staleFile>
>   </configuration>
>  </execution>
> </executions>
>
> </plugin>
>
> Any idea as what I'm doing wrong?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Issue with Maven's JAXB2 plugin

by Gérald Quintana :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/9/3 Tahmasebi, Hamid Reza <htahmase@...>:
> Hi,
>
> I'm running into an issue with Maven's JAXB2 plugin. I have 2 different schemas (aaaaTestCaseSchema.xsd and bbbbTestCaseSchema.xsd) and want 2 different packages (com.tmp.aaaa.dataDrivenTests and com.tmp.bbbb.dataDrivenTests) for those schemas. I followed the recommendation in plugin's FAQ page (http://mojo.codehaus.org/jaxb2-maven-plugin/faq.html <https://owa.ku.edu/exchweb/bin/redir.asp?URL=http://mojo.codehaus.org/jaxb2-maven-plugin/faq.html> ) and created 2 executions in JAXB2 plugin declaration with each execution having its own configuration declaration. In each configuration I specified the schema and package to be run for that execution. The problem is that the last execution always overwrites the first generated files, i.e., the plugin generates com.tmp.aaaa.dataDrivenTests package and its associated java files underneath this package and then overwrites it with com.tmp.bbbb.dataDrivenTests package and its java files when it runs the second execution. Here is my plugin declaration in pom.xml:
>
>

My XSD are not located in the test folder but i shouldn't matter.

Here is what I do, my project is organized like this:
src
  + main
     +  xsd
      |   + aaaa.xsd
      |   + bbbb.xsd
     +  xjb
          + aaaa.xjb
          + bbbb.xjb

.xjb files are used to configure the JAXB Binding and contain the
target package name. aaaa.xjbd contain something like this:

<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jxb:extensionBindingPrefixes="xjc">
    <jxb:bindings schemaLocation="../xsd/aaaa.xsd" node="/xs:schema">
        <jxb:schemaBindings>
            <jxb:package name="com.mycompany.myproject.aaaa.xml"/>
        </jxb:schemaBindings>
        <jxb:globalBindings>
            <xjc:simple/>
        </jxb:globalBindings>
    </jxb:bindings>
</jxb:bindings>

And I only have one plugin execution configuration:
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.2</version>
                <configuration>
                    <arguments>-extension</arguments>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Gérald

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Issue with Maven's JAXB2 plugin

by davidkarlsen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 3 Sep 2009, Tahmasebi, Hamid Reza wrote:


You can also try this plugin:
https://maven-jaxb2-plugin.dev.java.net/

> Hi,
>
> I'm running into an issue with Maven's JAXB2 plugin. I have 2 different schemas (aaaaTestCaseSchema.xsd and bbbbTestCaseSchema.xsd) and want 2 different packages (com.tmp.aaaa.dataDrivenTests and com.tmp.bbbb.dataDrivenTests) for those schemas. I followed the recommendation in plugin's FAQ page (http://mojo.codehaus.org/jaxb2-maven-plugin/faq.html <https://owa.ku.edu/exchweb/bin/redir.asp?URL=http://mojo.codehaus.org/jaxb2-maven-plugin/faq.html> ) and created 2 executions in JAXB2 plugin declaration with each execution having its own configuration declaration. In each configuration I specified the schema and package to be run for that execution. The problem is that the last execution always overwrites the first generated files, i.e., the plugin generates com.tmp.aaaa.dataDrivenTests package and its associated java files underneath this package and then overwrites it with com.tmp.bbbb.dataDrivenTests package and its java files when it runs the second execution. Here is my plugin declaration in pom.xml:
>
>
> <plugins>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>jaxb2-maven-plugin</artifactId>
> <version>1.2</version>
> <executions>
>  <execution>
>   <id>da</id>
>   <phase>test</phase>
>   <goals>
>    <goal>xjc</goal>
>   </goals>
>   <configuration>
>    <schemaDirectory>./src/test/resources</schemaDirectory>
>    <schemaFiles>aaaaTestCaseSchema.xsd</schemaFiles>
>    <removeOldOutput>true</removeOldOutput>
>    <generateDirectory>./src/test/java</generateDirectory>
>    <packageName>com.tmp.aaaa.dataDrivenTests</packageName>
>    <staleFile>${project.build.directory}/generated-sources/jaxb/.staleFlagAaaa</staleFile>
>   </configuration>
>  </execution>
>  <execution>
>   <id>scims</id>
>   <phase>test</phase>
>   <goals>
>    <goal>xjc</goal>
>   </goals>
>   <configuration>
>    <schemaDirectory>./src/test/resources</schemaDirectory>
>    <schemaFiles>bbbbTestCaseSchema.xsd</schemaFiles>
>    <removeOldOutput>true</removeOldOutput>
>    <generateDirectory>./src/test/java</generateDirectory>
>    <packageName>com.tmp.bbbb.dataDrivenTests</packageName>
>    <staleFile>${project.build.directory}/generated-sources/jaxb/.staleFlagBbbb</staleFile>
>   </configuration>
>  </execution>
> </executions>
>
> </plugin>
>
> Any idea as what I'm doing wrong?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
--
David J. M. Karlsen - +47 90 68 22 43
http://www.davidkarlsen.com
http://mp3.davidkarlsen.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email