highsource / jaxb2-basics

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

Migrating from v0.9.4 to v0.11.1... #78

Closed mestebangutierrez closed 6 years ago

mestebangutierrez commented 7 years ago

I'm currently using v0.9.4 together with -seems to be- legacy Fluent API plugin, Value Constructor plugin Commons Lang plugin, Default Value plugin, and Namespace-prefix plugin. My current POM looks like this:

<project
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <!-- =================================================================== -->
  <!--   MODULE COORDINATES                                                -->
  <!-- =================================================================== -->

  <-- Data here -->

  <!-- =================================================================== -->
  <!--   MODULE INFORMATION                                                -->
  <!-- =================================================================== -->

  <-- Data here -->

  <!-- =================================================================== -->
  <!--   BUILD SETTINGS                                                    -->
  <!-- =================================================================== -->

  <properties>
    <jaxb2.version>2.11.1</jaxb2.version>
    <jaxb2-basics.version>0.9.4</jaxb2-basics.version>
    <jaxb2-fluent-api.version>3.0</jaxb2-fluent-api.version>
    <jaxb2-default-value.version>1.1</jaxb2-default-value.version>
    <jaxb2-namespace-prefix.version>1.1</jaxb2-namespace-prefix.version>
    <jaxb2-value-constructor.version>3.0</jaxb2-value-constructor.version>
  </properties>

  <dependencies>

    <dependency>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
      <version>${jaxb.version}<version>
    </dependency>

    <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-core</artifactId>
      <version>${jaxb.version}<version>
    </dependency>

    <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-impl</artifactId>
      <version>${jaxb.version}<version>
    </dependency>

    <dependency>
      <groupId>org.jvnet.jaxb2_commons</groupId>
      <artifactId>jaxb2-basics</artifactId>
      <version>${jaxb2-basics.version}</version>
    </dependency>

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

    <!-- Other deps here -->

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.13.1</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <schemas>
                <schema>
                  <fileset>
                    <directory>${basedir}${file.separator}src${file.separator}main${file.separator}resources${file.separator}schemas</directory>
                    <includes>
                      <include>*.xsd</include>
                    </includes>
                  </fileset>
                </schema>
              </schemas>
              <bindings>
                <binding>
                  <fileset>
                    <directory>${basedir}${file.separator}src${file.separator}main${file.separator}bindings</directory>
                    <includes>
                      <include>*.xjb</include>
                    </includes>
                  </fileset>
                </binding>
              </bindings>
              <addCompileSourceRoot>true</addCompileSourceRoot>
              <extension>true</extension>
              <strict>true</strict>
              <args>
                <arg>-npa</arg>
                <arg>-Xdefault-value</arg>
                <arg>-Xfluent-api</arg>
                <arg>-Xvalue-constructor</arg>
                <arg>-Xnamespace-prefix</arg>
                <arg>-XtoString</arg>
                <arg>-Xequals</arg>
                <arg>-XhashCode</arg>
                <arg>-Xcopyable</arg>
              </args>
              <plugins>
                <plugin>
                  <groupId>org.jvnet.jaxb2_commons</groupId>
                  <artifactId>jaxb2-basics</artifactId>
                  <version>${jaxb2-basics.version}</version>
                </plugin>
                <plugin>
                  <groupId>org.jvnet.jaxb2_commons</groupId>
                  <artifactId>jaxb2-fluent-api</artifactId>
                  <version>${jaxb2-fluent-api.version}</version>
                </plugin>
                <plugin>
                  <groupId>org.jvnet.jaxb2_commons</groupId>
                  <artifactId>jaxb2-default-value</artifactId>
                  <version>${jaxb2-default-value.version}</version>
                </plugin>
                <plugin>
                  <groupId>org.jvnet.jaxb2_commons</groupId>
                  <artifactId>jaxb2-namespace-prefix</artifactId>
                  <version>${jaxb2-namespace-prefix.version}</version>
                </plugin>
                <plugin>
                  <groupId>org.jvnet.jaxb2_commons</groupId>
                  <artifactId>jaxb2-value-constructor</artifactId>
                  <version>${jaxb2-value-constructor.version}</version>
                </plugin>
              </plugins>
            </configuration>
          </execution>
        </executions>
        <!-- See https://github.com/jacobono/gradle-jaxb-plugin/issues/15 & 
        https://jaxb.java.net/nonav/2.2.11/docs/ch02.html#a-2-2-8 -->
        <dependencies>
          <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.12-b141001.1542</version>
          </dependency>
          <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>${jaxb.api.version}</version>
          </dependency>
          <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>${jaxb.api.version}</version>
          </dependency>
          <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-xjc</artifactId>
            <version>${jaxb.api.version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

</project>

When trying to change the jaxb2-basics.version to 0.11.1 I start seeing compiler problems with the generated code when the module is used in other modules, i.e., cannot access org.jvnet.jaxb2_commons.lang.CopyTo2, cannot access org.jvnet.jaxb2_commons.lang.Equal2, cannot access org.jvnet.jaxb2_commons.lang.HashCode2, cannot access org.jvnet.jaxb2_commons.lang.ToString2.

Are there any caveats regarding the migration from such and old version to a new one and the support to legacy plugins?

highsource commented 7 years ago

You will need to upgrade the version of jaxb2-basics-runtime everywhere. So far there is one known issue with this: #74. This will be fixed but right now this does not allow you to use old generated code and new generated code (0.11.1+) together. I am sorry about this, I was trying to make it a drop-in replacement but made a mistake there. When #74 is fixed you should be able to use old code and new code with the new runtime simultaneously. Strategies in the new runtime work with both old interfaces like CopyTo as well as new interfaces like CopyTo2.

Let me fix #74, then we'll see if there are other issues.

highsource commented 7 years ago

74 is fixed now, please build/try the latest snapshot.

highsource commented 6 years ago

@mestebangutierrez I'm closing this as there was no reaction from you.