在 Maven 中,我可以在当前项目上方指定一个相对路径吗? [英] In Maven, can I specify a relative path above my current project?

查看:14
本文介绍了在 Maven 中,我可以在当前项目上方指定一个相对路径吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在处理一个有大量项目要构建的项目时,正在快速学习 maven.

I'm learning maven on the fly while doing work on a project with a large set of projects to build.

目前,主构建中的一行使用绝对路径来指定一个目录,该目录是 subversion 存储库的一部分,但位于其目录的上方".

Currently a line in the main build uses an absolute path to specify a directory that is part of the subversion repository but "above" it's directory.

如:C:/work/project/eclipse",其中project"是签入目录,pom.xml 在C:/work/project/src/subproject/pom.xml"中

as in: "C:/work/project/eclipse" where "project" is the checked-in directory, and the pom.xml is in "C:/work/project/src/subproject/pom.xml"

我想将该行改为相对地址.

I'd like to make that line a relative address instead.

我尝试指定../../Eclipse....",但似乎不起作用.

I tried specifying "../../Eclipse....", put that didn't seem to work.

也可能是因为子项目的 pom 文件正在使用相同的变量.

It could also be because that same variable is being used by a sub-sub-project's pom file.

有什么建议(除了重写整个烂摊子,我只是对 maven 还不够了解)?

Any advice (aside from rewrite the whole mess, which I just don't know enough about maven to do yet)?

推荐答案

使用 Maven,事物相对于包含 pom.xml 的目录(由${basedir} 属性,称为基目录).但是,在某些情况下,您可能必须指定相对路径:

With Maven, things are relative to the directory containing the pom.xml (which is represented by the ${basedir} property and is called the base directory). There are however some situations where you could have to specify a relative path:

  • 如果 pom 不直接位于使用 元素的给定模块之上(请参阅 这个例子)
  • 如果模块没有使用各种 <module> 元素中的相对路径嵌套(即,如果您使用平面布局)(例如在 这个例子).
  • if a <parent> pom is not directly above a given module using a <relativePath> element (see this example)
  • if modules are not nested (i.e. if you use a flat layout) using a relative path in the various <module> elements (like in this example).

说了这么多,我不确定您的情况究竟是什么或您所描述的内容.

Having all that said, I'm not sure to understand what your situation exactly is or what you are describing.

如果可能的话,也许您应该展示 POM 的相关部分.

Maybe you should show the relevant parts of your POM if this is possible.

这篇关于在 Maven 中,我可以在当前项目上方指定一个相对路径吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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