如何从 ANT 执行 JAXB 编译器 [英] How to execute the JAXB compiler from ANT

查看:31
本文介绍了如何从 ANT 执行 JAXB 编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个项目中使用 JAXB.JAXB 的吸引力在于它与 JDK 捆绑在一起,我一直在命令行上使用 xjc.exe 从模式生成 .java 文件.我似乎找不到 JAXB ant 任务,确定在 http://jaxb.java.net 但是我想使用捆绑到 JDK 中的 JAXB 有什么方法可以从 ant 调用 JAXB xjc.exe 调用哪个类?

I am using JAXB on a project. the attraction of JAXB is that it is bundled with the JDK, I have been to use xjc.exe on the command line to generate the .java files from a schema. I can't seem to find the JAXB ant task, sure there is a download at http://jaxb.java.net however i want to use the JAXB that is bundled into the JDK is there some way to call JAXB from ant what class does the xjc.exe call on?

推荐答案

<target name="generate-jaxb-code">
    <java classname="com.sun.tools.internal.xjc.XJCFacade">
            <arg value="-p" />
            <arg value="com.example"/>
            <arg value="xsd/sample.xsd" />
    </java>
</target>

刚刚在tools.jar中搜索,发现com.sun.tools.internal中的XJCFacade.class测试了上面的代码它工作它产生的输出为xjc.exe 似乎XJC.exe调用此代码com.sun.tools.internal.xjc.XJCFacade

Just went hunting in the tools.jar and found the XJCFacade.class in com.sun.tools.internal tested the above code it works it produces the output as xjc.exe It seems that XJC.exe calls this code com.sun.tools.internal.xjc.XJCFacade

我的一个关键要求是 ant 文件可以在 eclipse 中运行,而不必包含 JDK 的路径名,这样文件就可以跨操作系统移植.我假设 tools.jar 通过已安装的 JRE 首选项选项包含在类路径中.

One of my key requirements was that the ant file had work within eclipse without having to include a path name to the JDK that way the file would be portable across operating systems. I am assuming that tools.jar is included on the classpath via the installed JRE preferences options.

这篇关于如何从 ANT 执行 JAXB 编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆