cmsantos
cmsantos

Reputation: 327

How customize package-info.java generated by JAXB2

Which is the best way to customize a generated package-info with the annotation @XmlJavaTypeAdapter? My package info already has "@javax.xml.bind.annotation.XmlSchema" annotation.

I'm using Maven and Liferay 6.2.

Upvotes: 1

Views: 2867

Answers (1)

Gambotic
Gambotic

Reputation: 824

My solution for the jaxb2-maven-plugin:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>jaxb2-maven-plugin</artifactId>
  <version>2.2</version>
  <executions>
    <execution>
      <id>bla</id>
      <phase>generate-resources</phase>
      <goals>
        <goal>xjc</goal>
      </goals>
      <configuration>
        <sources>
          <source>${somevariable}/somexsd.xsd</source>
        </sources>
        <outputDirectory>src/main/generated-sources/jaxb/</outputDirectory>
        <encoding>UTF-8</encoding>
        <locale>en</locale>
        <packageName>de.something.generated</packageName>
        <noPackageLevelAnnotations>true</noPackageLevelAnnotations>
      </configuration>
    </execution>
  </executions>
</plugin>

with "noPackageLevelAnnotations=true" there will be no generated package-info.java in your package "de.something.generated"

now you only have to add under your normal src/main/java the same package "de.something.generated" and place there your own package-info.java

just build and enjoy ;)

Upvotes: 1

Related Questions