gpt4 book ai didi

maven-2 - 如何将我的源代码树中的文件添加到 Maven 站点

转载 作者:行者123 更新时间:2023-12-04 18:53:31 24 4
gpt4 key购买 nike

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

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

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

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

我还尝试使用 .apt 文件,该文件具有指向 foo.xsd 的链接,该链接被复制到 target/classes 目录。在我执行 site:deploy 之前,这一直有效,因为它只复制目标/站点目录。

谢谢,

查尔斯

最佳答案

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

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

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>

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

关于maven-2 - 如何将我的源代码树中的文件添加到 Maven 站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2503293/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com