问题描述
我在处理一个有大量项目要构建的项目时,正在快速学习 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:
- 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 中,我可以在当前项目上方指定一个相对路径吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!