我有一个使用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目录.这有效,直到我做一个站点:部署,因为它只复制目标/站点目录.
谢谢,
查尔斯
要向您的站点添加资源,您必须将它们包含在资源目录中:
.
`-- src
`-- site
`-- resources
`-- foo.xsd
要使此文件与生成的文件保持同步,您只需使用maven antrun插件将生成的文件复制src/main/resources到上述位置,例如在此pre-site阶段:
<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>
Run Code Online (Sandbox Code Playgroud)
最后,foo.xsd在站点描述符(site.xml文件)中添加一个链接.