I have a module in my intellij IDE, which have its own maven project structure (src/main/java, src/main/test). In this project, I coded in a package JAXB classes (java). Then in this package, I have my package-info used normally, by the schemagen goal of the org.codehaus.mojo:jaxb2-maven-plugin. I found that it is not the case. When the XSD is generated in target output folder. My date are still convert to string like this :
<xs:element minOccurs="0" name="dateSSP" type="xs:string"/>
I'am expecting a dateTime type like this :
<xs:element minOccurs="0" name="dateSSP" type="xs:dateTime"/>
It is clearly that my package-info.java file is ignored.
But what is strange, is that when I full build, not only the module, but the whole main project (multi module project), the generated XSD for this module is right ! I have the dateTime
type inside XSD. But built alone, the generated XSD has a string
type.
I don't know why.
Here the configuration (basic) of the plugin :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>schemagen</id>
<goals>
<goal>schemagen</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<configuration>
<clearOutputDir>true</clearOutputDir>
<sources>
<source>src/main/java/com/allegoria/notariat/corpus/redaction/ro</source>
<source>src/main/java/com/allegoria/notariat/business</source>
</sources>
<!--<verbose>true</verbose>-->
<transformSchemas>
<transformSchema>
<uri>https://www.signatureparfiducial.fr/redaction</uri>
<toFile>corpus-redaction.xsd</toFile>
</transformSchema>
</transformSchemas>
<schemaSourceExcludeFilters>
<noAdapter implementation="org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter">
<patterns>
<pattern>Adapter\.java</pattern>
</patterns>
<patternPrefix>.*</patternPrefix>
</noAdapter>
</schemaSourceExcludeFilters>
</configuration>
</plugin>
Sorry my mystake ;). Inside the package-info.java, the DateAdapter class was in another package outside of the concerned module ; it was in another module. So as I build only the module having the JAXB classes, the DateAdapter is not build and then ignored by XmlAdapters.
Thx.