需要一个好的“家” Maven 构建期间 Web 应用程序的目录
我有一个 Java Web 应用程序,它使用 JNDI 来确定其“主”目录,其中发生各种配置文件和日志记录。在 Maven 构建期间,我们在位于 settings.xml 的属性中设置主目录位置。在构建过程中,通过 Maven 资源过滤,该属性又被放入 Jetty/Tomcat JNDI 文件中。一切都很好。
然而,这种设置要求一台机器上一次只能进行一个 Maven 构建,这很快就会成为我们的 Hudson CI 服务器的问题。它还要求用户在构建之前创建此目录,这有助于破坏构建的可移植性。理想情况下,我可以通过在父 POM 中定义变量来使用父 POM 项目的“target”目录作为“home”目录:
但这不起作用,因为每个 Maven 模块都会将 webapp-home
重新定义为不同的东西。我不知道为什么。如果我能解决这个问题,我就万事大吉了。
否则,我可以使用什么作为一个好的临时“主”或“工作”目录,该目录对于构建是唯一的并且在构建中的所有 Maven 模块中都是不变的?额外的问题是:如果目录不存在,我可以让 Maven 为我创建该目录吗?
I have a Java web application that uses JNDI to determine its "home" directory where various configuration files and logging takes place. During a Maven build, we set the home directory location in a property that is located in settings.xml. This property in turn gets put into the Jetty/Tomcat JNDI file during the build by Maven resource filtering. Everything works great.
However, this set up requires that only one Maven build can happen on a machine at a time, which will be a problem soon for our Hudson CI server. It also requires that users create this directory ahead of a build, which helps to break build portability. Ideally I could use the "target" directory of the parent POM project as the "home" directory by defining a variable in the parent POM:
<webapp-home>${project.basedir}/target<webapp-home>
But this doesn't work because each Maven module redefines webapp-home
to be something different. I have no idea why. If I could solve THAT problem, I'd be all set.
Otherwise, what can I use as a good temporary "home" or "working" directory, that is unique to a build and is constant across all Maven modules in the build? And the bonus question is: Can I have Maven create the directory for me if it doesn't exist?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们使用全局“out”目录作为 webapp-home,每个项目都有子文件夹
We're using a global "out" directory as webapp-home, with subfolders for every project