如何将文件从我的源树添加到Maven站点 [英] How to Add a File from my source tree to Maven Site

查看:68
本文介绍了如何将文件从我的源树添加到Maven站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Jersey/JAXB的Maven 2 RESTful应用程序.我从架构文件生成JAXB Bean,该架构文件位于我的资源目录中,例如src/main/resources/foo.xsd.

I have a Maven 2 RESTful application using Jersey/JAXB. I generate the JAXB beans from a schema file, where the schema file is in my resources directory, e.g., src/main/resources/foo.xsd.

我想在生成的Maven网站中为我的项目添加foo.xsd文件,以便客户端在编写RESTful调用时可以看到XML模式.

I want to include foo.xsd file in the generated Maven site for my project, so that clients can see the XML schema when writing RESTful calls.

如何在网站中包含foo.xsd?

How can I include foo.xsd in the site?

我可以在src/main/site/...中拥有该文件的副本,然后更新我的site.xml以指向它(或者具有一个指向其内容的.apt),但是我没有之所以这样,是因为我仍在调整foo.xsd,并且不想每次更新时都必须记住要复制它.那只是不好的做法.

I could have a copy of the file in src/main/site/..., and then update my site.xml to point to it (or have a .apt whose contents point to it), but I don't like that because I'm still tweaking foo.xsd, and don't want to have to remember to copy it each time I update it. And that's just bad practice.

我还尝试了一个.apt文件,该文件具有指向foo.xsd的链接,该链接被复制到target/classes目录中.在我执行site:deploy之前,该方法一直有效,因为那只会复制目标/站点目录.

I also tried having a .apt file that has a link to the foo.xsd which gets copied to the target/classes directory. That works until I do a site:deploy, because that only copies the target/site directory.

谢谢

查尔斯

推荐答案

要将资源添加到您的站点,您将必须将它们包括在资源目录中:

To add resources to your site, you'll have to include them in a resources directory:


.
`-- src
    `-- site
        `-- resources
            `-- foo.xsd

要使此文件与生成的文件保持同步,您可以简单地使用maven antrun插件将生成的文件从src/main/resources复制到上述位置,例如在pre-site阶段:

To keep this file in sync with the generated one, you could simply use the maven antrun plugin to copy the generated file from src/main/resources to the above location, for example during the pre-site phase:

  <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
      <execution>
        <phase>pre-site</phase>
        <goals>
          <goal>run</goal>
        </goals>
        <configuration>
          <tasks>
            <copy file="src/main/resources/foo.xsd" todir="src/site/resources"/>
          </tasks>
        </configuration>
      </execution>
    </executions>
  </plugin>

最后,在您的站点描述符(site.xml文件)中添加指向该foo.xsd的链接.

Finally, add a link to this foo.xsd in your site descriptor (the site.xml file).

这篇关于如何将文件从我的源树添加到Maven站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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