Using XJB with jaxb2-maven-plugin -
i have multi-module maven project in following structure:
root-module |__module-a | |__src | |__main | |__xsd | | |__my.xsd | |__xjb | |__my.xjb |__module-b
the pom root module aggregates module , b (among other things):
<project> <artifactid>root-module</artifactid> <packaging>pom</packaging> <modules> <module>module-a</module> <module>module-b</module> </modules> </project>
and pom module follows (among other things):
<project> <parent> <artifactid>root-module</artifactid> </parent> <artifactid>module-a</artifactid> <properties> <my-definitions.xsd>${basedir}/src/main/xsd/my.xsd</my-definitions.xsd> <my-bindings.xjb>${basedir}/src/main/xjb/my.xjb</my-bindings.xjb> <my.output>${basedir}/target/generated-sources/jaxb/my</my.output> </properties> <build> <plugins> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>jaxb2-maven-plugin</artifactid> <executions> <execution> <id>generate-my-classes</id> <phase>generate-sources</phase> <goals><goal>xjc</goal></goals> <configuration> <sources><source>${my-definitions.xsd}</source></sources> <xjbsources><xjbsource>${my-bindings.xjb}</xjbsource></xjbsources> <outputdirectory>${my.output}</outputdirectory> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
so when run mvn @ module-a, works fine , build succeeds. when run @ root-module, exception xjc plugin tries find bindings file under root-module:
com.sun.istack.saxparseexception2; ioexception thrown when processing "file:/home/root-module/src/main/xjb/my.xjb". exception: java.io.filenotfoundexception: /home/root-module/src/main/xjb/my.xjb (the system cannot find path specified).
what interesting is, able locate xsd correctly:
[error] failed execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.1:xjc (generate-my-classe) on project module-a: [error] +=================== [xjc error] [error] | [error] | 0: file:/home/root-module/module-a/src/main/xsd/my.xsd [error] | [error] +=================== [end xjc error]
- any clues?
- is configuration issue in build script?
specifics of build system:
using maven 3.2.5 <groupid>org.codehaus.mojo</groupid> <artifactid>jaxb2-maven-plugin</artifactid> <version>2.1</version>
referring jaxb2 maven plugin documentation here. searched few related questions on so, not explain specific problem anywhere.
update: looks open issue. keeping thread open in case there workaround.
updating version 2.2 of plugin appears work.
<groupid>org.codehaus.mojo</groupid> <artifactid>jaxb2-maven-plugin</artifactid> <version>2.2</version>
i had same problem when using version 2.1 of plugin. changing version 2.2 fixed issue.
Comments
Post a Comment