highsource / jaxb2-basics

Useful plugins and tools for JAXB2.
BSD 2-Clause "Simplified" License
109 stars 54 forks source link

jaxb2-basics dependency is required to be defined #97

Closed KroArtem closed 6 years ago

KroArtem commented 6 years ago

In Using-JAXB2-Basics-Plugins wiki page it's said:

In Maven builds, you have to list your JAXB plugin artifacts in configuration/plugins/plugin elements (you don't need to define the dependencies, Maven will take care of dependency resolution)

However if I do not define dependency, generating fails. maven-jaxb2-plugin 0.14.0, jaxb2-basics 0.12.0

This will not compile:

        <plugins>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.14.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaDirectory>src/main/resources/xsd</schemaDirectory>
                    <bindingDirectory>src/main/resources/xsd</bindingDirectory>
                    <removeOldOutput>true</removeOldOutput>
                    <extension>true</extension>
                    <verbose>false</verbose>
                    <readOnly>true</readOnly>
                    <args>
                        <arg>-Xsetters</arg>
                        <arg>-Xfluent-api</arg>
                        <arg>-Xinheritance</arg>
                        <arg>-Xequals</arg>
                        <arg>-XhashCode</arg>
                    </args>
                    <plugins>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-basics</artifactId>
                            <version>0.12.0</version> <!-- "New" version 1.11.1 is in fact older than 0.12.0-->
                        </plugin>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-fluent-api</artifactId>
                            <version>3.0</version>
                        </plugin>
                    </plugins>
                </configuration>
            </plugin>
        </plugins>
    </build>

The same code with defined dependency will compile:

       <dependency>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics</artifactId>
            <version>0.12.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.14.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaDirectory>src/main/resources/xsd</schemaDirectory>
                    <bindingDirectory>src/main/resources/xsd</bindingDirectory>
                    <removeOldOutput>true</removeOldOutput>
                    <extension>true</extension>
                    <verbose>false</verbose>
                    <readOnly>true</readOnly>
                    <args>
                        <arg>-Xsetters</arg>
                        <arg>-Xfluent-api</arg>
                        <arg>-Xinheritance</arg>
                        <arg>-Xequals</arg>
                        <arg>-XhashCode</arg>
                    </args>
                    <plugins>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-basics</artifactId>
                            <version>0.12.0</version> <!-- "New" version 1.11.1 is in fact older than 0.12.0-->
                        </plugin>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-fluent-api</artifactId>
                            <version>3.0</version>
                        </plugin>
                    </plugins>
                </configuration>
            </plugin>
        </plugins>
    </build>

Either this is a bug or wiki page should be edited.

highsource commented 6 years ago

Please try to include:

    <dependency>
        <groupId>org.jvnet.jaxb2_commons</groupId>
        <artifactId>jaxb2-basics-runtime</artifactId>
        <version>...</version>
    </dependency>

as dependency instead.

Actually the wording is correct in a sense that your project does not need to depend on org.jvnet.jaxb2_commons:jaxb2-basics.

However, some plugins generate code which has a runtime dependency on org.jvnet.jaxb2_commons:jaxb2-basics-runtime. I'll include that in the documentation.

highsource commented 6 years ago

1.11.1 was release by mistake, there's also 1.11.1-PUBLISHED-BY-MISTAKE release to point to this fact.

I've updated the docs:

https://github.com/highsource/jaxb2-basics/wiki/Using-JAXB2-Basics-Plugins

KroArtem commented 6 years ago

Thanks for clarification!