我目前有一个 ant 任务,它可以很好地从 xsd 和 xjb 绑定文件生成我的域对象。它基于自定义插件创建注释并在我需要的地方注入代码。
现在我正试图将所有这些移至 Maven,虽然我可以生成对象,但我无法获取代码来注入或添加注释。我的 POM 插件入口如下:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<bindingDirectory>src/main/resources/jaxb/bindings</bindingDirectory>
<generatePackage>com.noush.web.domain.model.data</generatePackage>
<extension>true</extension>
<verbose>true</verbose>
<args><!-- <arg>-XtoString</arg> -->
<!-- I want to use commons-lang-plugin to generate toString but this can
wait <arg>-Xcommons-lang</arg> <arg>-Xcommons-lang:ToStringStyle=SIMPLE_STYLE</arg> -->
<arg>-Xannotate</arg>
<arg>-Xinject-code</arg>
</args>
<plugins>
<plugin>
<groupId>noush</groupId>
<artifactId>code-expander-plugin</artifactId>
<version>1.0</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.0</version>
</plugin>
</plugins>
</configuration>
</plugin>
对象被创建但没有任何注入的代码或注释。输出没有给出任何错误的迹象。
如果有帮助,这里是我的工作蚂蚁配置:
<target name="defineXjcTask">
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" classpathref="xjcLib" />
</target>
<target name="generateJaxb">
<xjc target="${build.generated}" package="${noushweb.domain.model.jaxb.package}">
<arg value="-verbose"/>
<arg value="-extension"/>
<arg value="-Xcommons-lang"/>
<arg value="-Xcommons-lang:ToStringStyle=SIMPLE_STYLE"/>
<arg value="-Xinject-code"/>
<arg value="-Xannotate"/>
<schema dir="${build.directory}/jaxb/bindings" includes="${matmWS.mmmws.data.filename}" />
<binding dir="${build.directory}/jaxb/bindings" includes="${matmWS.mmmws.binding.filename}"/>
<produces dir="${build.generated}/${noushweb.domain.model.jaxb.package.dir}" includes="**/*.java" />
</xjc>
</target>
<path id="xjcLib">
<pathelement location="${lib.dir}/jaxb-ri-2.0.5/lib/jaxb-xjc.jar" />
<pathelement location="${ib.dir}/jaxb-ri-2.0.5/lib/jaxb-api.jar" />
<pathelement location="${lib.dir}/jaxb-ri-2.0.5/lib/jaxb-impl.jar" />
<pathelement location="${lib.dir}/jaxb-ri-2.0.5/lib/activation.jar" />
<pathelement location="${lib.dir}/jaxb-ri-2.0.5/lib/jsr173_1.0_api.jar" />
<pathelement location="../lib/stax-api-1.0-2.jar" />
<pathelement location="../lib/jaxb-commons-lang-plugin-2.2.jar" />
<pathelement location="${lib.dir}/commons-lang-2.4/lib/commons-lang-2.4.jar" />
<pathelement location="../lib/code-expander-plugin.jar" />
<pathelement location="../lib/jaxb2-basics-runtime-0.6.0.jar" />
<pathelement location="../lib/jaxb2-basics-tools-0.6.0.jar" />
<pathelement location="../lib/jaxb2-basics-annotate-0.6.0.jar" />
<pathelement location="../lib/annox-0.5.0.jar" />
<pathelement location="${lib.dir}/axis-1_4/lib/commons-logging-1.0.4.jar" />
<pathelement location="${lib.dir}/hibernate-validator-4.1.0.Final/hibernate-validator-4.1.0.Final.jar"/>
<pathelement location="${lib.dir}/hibernate-validator-4.1.0.Final/validation-api-1.0.0.GA.jar"/>
</path>
我想我可以使用 antrun 类型的设置,但我希望我可以让它工作。
任何想法都会受到欢迎。
谢谢努什