Hi.
Comments inline.
I'd suggest that you try it with the maven-jaxb2-plugin:
https://maven-jaxb2-plugin.dev.java.net
https://maven-jaxb2-plugin.dev.java.net/docs/guide.html
> I have a maven 2 Project in Netbeans 5.0 with a xsd file.
> Compiling the XML Schema with the maven plugin works fine.
> But, I have a problem. I want to use vendor extension (I need to inject
> code in the generated classes).
> This doesn't work.
> Here is how I did it :
> I set up the project to compile my XML Schema : enable jaxb2 maven
> plugin.
> I created a maven plugin containing the extension and I put a reference
> to it into my POM file.
As far as I understand, your code injector is just a JAXB plugin. In this case you don't need to write a separate maven plugin. Just make your JAXB plugin available to the maven-jaxb-plugin (add your artifact to plugin's dependencies). If you have created your plugin correctly, then it becomes available to XJC. Then you have to enable it with the command-line argument.
> I enabled in the config of the maven-jaxb-plugin extensionsions with
> the following tag <extension>true</extension>
> I also put the following tag <args>-Xsync-methods</args> (only to test)
>
> I build the project without any problem but I have no synchronized methods
>
> I have put my xsd file and the POM file.
> Note that in the xsd file I tried also to use the code-injector plugin
> and I removed the following line
> jaxb:extensionBindingPrefixes="ci"
>
> Netbeans complains with that line.
You still need extensionBindingPrefixes, even if NetBeans complains. If you omit that, JAXB will not recognise your XML and will complain.
> Can you explain me how to do it (and maybe add an article in your blog
> about it)
With my plugin (maven-jaxb2-plugin) you can try the following:
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.jaxb.plugins</groupId>
<artifactId>jaxb-code-injector</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<extension>true</extension>
<args>
<arg>-Xinject-code</arg>
</args>
</configuration>
</plugin>
</plugins>
</build>
ps. Consider hosting your JAXB plugin on jaxb2-commons.dev.java.net.
Bye.
/lexi
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer