1

我需要config.xml在我的 Eclipse 项目中有一个文件,并将该文件用作 Maven 目标的输入。该目标将用于在目录下(也在我的项目中)config.xml自动生成代码(XML 和 Java )。generated/

因此:

MyProject/
    src/main/config
        config.xml
    src/main/java
        (All my Java source)
    (rest of my project)
    generated
        source/
            java/
            xml/

因此,Maven 目标将在任何compilebuild相关目标之前启动,并将用于config.xml根据需要填充generated/source/*目录。然后,这些资源将可用于后续目标的处理。

这样的工具存在吗?我能找到的最接近的是XDoclet,但我对它有两个担忧:

  1. 我不知道它有多灵活。即,我可以在多大程度上将我自己的配置“东西”放入 config.xml,给 XDoclet 一个 XSD 并让它去城里;更多关于这下面
  2. 似乎找不到任何 Maven 目标/插件

至于第一项/问题,我的意思是:理想情况下,我想将任何类型的 XML 放入config.xml. 因此,这个理想的工具应该只需要用于该 XML 的 XSD,以及一些 XSLT(或类似工具)来确定如何从配置文件中找到的 XML 自动生成代码。

我不确定 XDoclet 是否允许这种灵活性。

有什么想法或建议吗?一定有这样的东西!提前致谢,

4

2 回答 2

1

XDoclet is pretty flexible, but it purpose it to process java sources and generate something out of it. If you start with some xml, your best choice would be XSLT transformation - xdoclet ist not suitable for this.

于 2011-11-02T20:03:44.860 回答
0

I use antrun and the xslt task that works with Ant to generate other code artifacts. Then use build-helper plugin to add the generated folders to the source folder list. This should provide you with the most flexible base of writing the code and will also work with m2e (though you need to run the maven generate-sources yourself as antrun won't run automatically as there is no connector for it yet).

于 2011-11-03T01:48:09.847 回答