需要一个好的“家” Maven 构建期间 Web 应用程序的目录

发布于 2024-10-04 15:30:55 字数 627 浏览 0 评论 0原文

我有一个 Java Web 应用程序,它使用 JNDI 来确定其“主”目录,其中发生各种配置文件和日志记录。在 Maven 构建期间,我们在位于 settings.xml 的属性中设置主目录位置。在构建过程中,通过 Maven 资源过滤,该属性又被放入 Jetty/Tomcat JNDI 文件中。一切都很好。

然而,这种设置要求一台机器上一次只能进行一个 Maven 构建,这很快就会成为我们的 Hudson CI 服务器的问题。它还要求用户在构建之前创建此目录,这有助于破坏构建的可移植性。理想情况下,我可以通过在父 POM 中定义变量来使用父 POM 项目的“target”目录作为“home”目录:

${project.basedir}/target;

但这不起作用,因为每个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情何以堪。 2024-10-11 15:30:55

我们使用全局“out”目录作为 webapp-home,每个项目都有子文件夹

<properties>
  <root.dir>${basedir}/..</root.dir>
  <output.dir>${root.dir}/out</output.dir>
  <output.wardir>${output.dir}/wars</output.wardir>
</properties>
...
<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <webappDirectory>
      ${output.wardir}/exploded/${project.artifactId}
    </webappDirectory>
   </configuration>
</plugin>

We're using a global "out" directory as webapp-home, with subfolders for every project

<properties>
  <root.dir>${basedir}/..</root.dir>
  <output.dir>${root.dir}/out</output.dir>
  <output.wardir>${output.dir}/wars</output.wardir>
</properties>
...
<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <webappDirectory>
      ${output.wardir}/exploded/${project.artifactId}
    </webappDirectory>
   </configuration>
</plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文