This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 189596

Summary: JAXB wizard in Maven doesn't generate java sources from xsd
Product: xml Reporter: Milan Kuchtiak <mkuchtiak>
Component: JAXBAssignee: Milan Kuchtiak <mkuchtiak>
Status: RESOLVED FIXED    
Severity: normal CC: jglick, mgrebac, pjiricka
Priority: P2    
Version: 6.x   
Hardware: PC   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description Milan Kuchtiak 2010-08-17 13:25:41 UTC
The wizard only results in copying/downloading schema file into xml-resources directory.
Some kind of maven xjc plugin should be included to pom.xml.
Comment 1 Jesse Glick 2010-08-17 14:58:22 UTC
See bug #185139 comment #19 for background. (Not sure if there is any general task among quality testers to check for significant pieces of functionality relating to domain technologies like this that would make sense for Maven projects but are simply missing.)

(In reply to comment #0)
> Some kind of maven xjc plugin should be included to pom.xml.

http://stackoverflow.com/questions/2432859/difference-of-maven-jaxb-plugins

Looks like maven-jaxb2-plugin is preferred.
Comment 2 Milan Kuchtiak 2010-08-18 08:19:47 UTC
> Looks like maven-jaxb2-plugin is preferred.

Yes. however from the the Netbeans perspective I think the first plugin (SUNs) is more suitable. I'd ask Martin Grebac on his opinion.

The JAXB wizard is just accidentally running in Maven projects. Nobody implemented it yet for Maven specifically.

At least these steps should be done:

- xml schema files should be included to src/main/resources directory
- maven-jaxb-plugin (or maven-jaxb2-plugin) should be included to pom file

We may omit to implement UI changes (nodes, actions) in Maven project for JAXB.
The wizard may just put all schema files to src/main/resources and generate one generic plugin execution, or (may be better) to generate specific plugin execution for each xsd.

Sample :
            <plugin>
                <groupId>com.sun.tools.xjc.maven2</groupId>
                <artifactId>maven-jaxb-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generatePackage>org.example.po1</generatePackage>
                            <includeSchemas>
                                <includeSchema>po1/*.xsd</includeSchema>
                            </includeSchemas>
                        </configuration>
                        <id>Po1</id>
                    </execution>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generatePackage>org.example.po2</generatePackage>
                            <includeSchemas>
                                <includeSchema>po2/*.xsd</includeSchema>
                            </includeSchemas>
                        </configuration>
                        <id>Po2</id>
                    </execution>
                </executions>
            </plugin>
Comment 3 Milan Kuchtiak 2010-08-18 08:39:10 UTC
I checked both the maven-jaxb-plugin(1) and maven-jaxb2-plugin(2).
The second one generates some jaxb bindings (sun-jaxb.episode) to META-INF directory.
Comment 4 Jesse Glick 2010-08-18 16:55:37 UTC
(In reply to comment #3)
> maven-jaxb2-plugin [...] generates some jaxb bindings (sun-jaxb.episode)
> to META-INF directory.

Yes, this seems to be to support multiple-episode compilation, mentioned somewhere in its documentation. As far as I can tell it is harmless for simple cases.

(In reply to comment #2)
> from the the Netbeans perspective I think the first plugin (SUNs)
> is more suitable.

https://maven-jaxb2-plugin.dev.java.net/ ~ org.jvnet.jaxb2.maven2:maven-jaxb2-plugin is linked to from the Glassfish subsite and seems to be the most actively maintained plugin (commits in last two weeks). It is hard to keep track of all the similarly-named alternatives, unfortunately!
Comment 5 Quality Engineering 2010-08-27 03:17:08 UTC
Integrated into 'main-golden', will be available in build *201008270001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/0e6bc4651ab3
User: mkuchtiak@netbeans.org
Log: #189596: create infrastructure to make JAXB wizard work in no-Ant project types
Comment 6 Milan Kuchtiak 2010-08-27 17:27:44 UTC
Fixed.
Comment 7 Quality Engineering 2010-08-28 03:46:04 UTC
Integrated into 'main-golden', will be available in build *201008280001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/f00c1ac7c8ed
User: mkuchtiak@netbeans.org
Log: #189596: move JAXBWizModuleConstants to spi package