users@jaxb.java.net

RE: Maven 2 Jaxb2 plugin available.

From: Jonathan Johnson <jonjohnson_at_mail.com>
Date: Fri, 5 May 2006 23:44:24 -0400

Kohsuke,

I’m afraid I need a second pair of eyes on this problem. My settings appear
to have no effect on the produces/depends XJC2Task mechanism. I‘m added the
files to the produces and depends lists, but both Bill and I are seeing the
compilation happen every time.

Perhaps I’m not populating the FileSets with all the correct values or does
the set of depends have to match the produces? I’m just not clear on how
the dependency mechanism works, so it is hard to tell what the correct
settings should be.

If you look at com.sun.tools.xjc.maven2.XJCMojo.java after line 240 you can
see I’m adding Bindings, Schemas and the POM dependency using

        FileSet dependencies = new FileSet();
        dependencies.setDir(schemaDirectory);
        dependencies.addFilename([Bindings, Schemas and the POM])
        [XJC2Task].addConfiguredDepends(dependencies);

And setting the produces set as

        FileSet products = new FileSet();
        StringBuilder fullPath = new StringBuilder(256);

        fullPath.append(generateDirectory);
        if (generatePackage != null)
        {
            fullPath.append(File.separator)
            .append(generatePackage.replace('.', File.separatorChar));
        }
        products.setDir(new File(fullPath.toString()));
        products.addFilename(createFilenameSelector("*.java"));
        [XJC2Task].addConfiguredProduces(products);

The logging from the plugin reports the dependencies and the XJC2Task
messages, indicating a compile occurs each time.

[INFO] Schema dependency:
D:\development\jaxb2-sources\jaxbMavenGenerateTest\src
\main\resources\purchaseorder.xsd
[INFO] pom dependency:
D:\development\jaxb2-sources\jaxbMavenGenerateTest\pom.xm
l
[INFO] XJC compile using schema:
D:\development\jaxb2-sources\jaxbMavenGenerateT
est\src\main\resources\purchaseorder.xsd
[INFO] build id of XJC is 2.0-03/16/2006 12:05 AM(kohsuke)-fcs
[INFO] Checking timestamp of
D:\development\jaxb2-sources\jaxbMavenGenerateTest\
src\main\resources\purchaseorder.xsd
[INFO] the last modified time of the inputs is 1146538915203
[INFO] the last modified time of the outputs is -9223372036854775808
[INFO] Compiling
file:/D:/development/jaxb2-sources/jaxbMavenGenerateTest/src/ma
in/resources/purchaseorder.xsd



- Jon

-----Original Message-----
From: William Simons [mailto:william.simons_at_childrens.harvard.edu]
Sent: Tuesday, April 18, 2006 2:24 PM
To: users_at_jaxb.dev.java.net
Subject: Re: Maven 2 Jaxb2 plugin available.

Hi Jon,

Thanks again for all your hard work.

I noticed today that my schemas are still compiled every time that I run
install even if they haven’t changed. Did the depends/produces fix make it
into the release? Sorry I didn’t report on this before.

Bill


On 4/14/06 10:32 AM, "Jonathan Johnson" <jonjohnson_at_mail.com> wrote:
Excellent. Sounds like its ready for publication. I will work on getting
the plugin onto Maven 2 Ibiblio. I’ll bump the version 1.1

All of the log messages in the plugin are wrapped in isVerbose checks. Lots
of information comes out if you set verbose=true. The messages you are
seeing “Compiling file..” and “Writing output to..” seem to be the standard
non-verbose output of the xjc compiler.


-----Original Message-----
From: Simons, William [ mailto:William.Simons_at_childrens.harvard.edu]
<mailto:William.Simons_at_childrens.harvard.edu%5D>
Sent: Friday, April 14, 2006 9:52 AM
To: users_at_jaxb.dev.java.net
Subject: RE: Maven 2 Jaxb2 plugin available.

Works like a charm!

It looks like I get these two lines for each schema that its compiling:
[INFO] Compiling
file:/Users/bsimons/projects/svn/ping/server/phr-xml/src/main/r
esources/actions.xsd and others
[INFO] Writing output to
/Users/bsimons/projects/svn/ping/server/phr-xml/target/
generated-sources/xjc

Is that expected?

Great work My project couldn't proceed without it.

Bill

  _____


From: Jonathan Johnson [ mailto:jonjohnson_at_mail.com]
<mailto:jonjohnson_at_mail.com%5D>
Sent: Thu 4/13/2006 9:15 PM
To: users_at_jaxb.dev.java.net
Subject: RE: Maven 2 Jaxb2 plugin available.
Many thanks Bill !!

I did not test a scenario where the “generatedPackage” was left undefined
(null). Your example configuration was helpful. Its now corrected. I
updated the zip file at

https://jaxb.dev.java.net/jaxb-maven2-plugin/

Please let me know you make out.

Cheers!

- Jonathan


-----Original Message-----
From: William Simons [ mailto:william.simons_at_childrens.harvard.edu]
<mailto:william.simons_at_childrens.harvard.edu%5D>
Sent: Thursday, April 13, 2006 10:09 AM
To: users_at_jaxb.dev.java.net
Subject: Re: Maven 2 Jaxb2 plugin available.

Hi Jonathan,

I just tried this out and got a NullPointerException:

java.lang.NullPointerException
        at com.sun.tools.xjc.maven2.XJCMojo.execute(XJCMojo.java:272)
        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManage
r.java:412)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLife
cycleExecutor.java:534)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle
(DefaultLifecycleExecutor.java:475)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifec
ycleExecutor.java:454)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFail
ures(DefaultLifecycleExecutor.java:306)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(Defa
ultLifecycleExecutor.java:273)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycle
Executor.java:140)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)


Here is my plugin configuration:

            <plugin>
                <groupId>com.sun.tools.xjc.maven2</groupId>
                <artifactId>maven-jaxb-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <extension>true</extension>
                    <catalog>src/main/resources/catalog.cat</catalog>
                </configuration>
            </plugin>


Note that the previous version of the plugin that you sent me worked fine.



On 4/12/06 9:47 PM, "Jonathan Johnson" <jonjohnson_at_mail.com> wrote:
To All Maven 2 and JAXB / xjc users:

A Maven 2 Jaxb2 plugin is available for everyone. Instructions for
downloading and usage are found here:

https://jaxb.dev.java.net/jaxb-maven2-plugin/

Comments and feedback are welcome of course.

Thanks to William Simons and Kohsuke Kawaguchi for pointing out these
problems that have been fixed.

- Removed excessive compiler output.
- xjc now only regenerates when binding, schema or pom.xml file are updated.