Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Maven, can I specify a relative path above my current project?

Tags:

maven-2

build

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

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.

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.

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

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

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

like image 786
Bill K Avatar asked Jan 29 '10 22:01

Bill K


People also ask

How do you create a relative path in Maven project?

Parent POM Relative Path By default, Maven looks for the parent POM first at project's root, then the local repository, and lastly in the remote repository. If parent POM file is not located in any other place, then you can use code tag. This relative path shall be relative to project root.

What is relative path in POM xml?

relativePath allows you to select a different location, for example when your structure is flat, or deeper without an intermediate parent POM. However, the group ID, artifact ID and version are still required, and must match the file in the location given or it will revert to the repository for the POM.

How do you specify an absolute path in POM xml?

You cannot use an absolute path for your parent pom, the name itself of the configuration entry is quite self explanatory (relative path). From the official Maven model documentation for this element: The relative path of the parent pom. xml file within the check out.


1 Answers

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.

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

like image 123
Pascal Thivent Avatar answered Sep 19 '22 19:09

Pascal Thivent