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

后端 未结 2 1536
后悔当初
后悔当初 2020-12-14 15:24

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 speci

相关标签:
2条回答
  • 2020-12-14 15:30

    Ideally the pom.xml should be in the same directory as your src directory. For eg suppose you have checked out your project from svn into a folder C:/work/project, then keep the main pom.xml in C:/work/project. src should also be in C:/work/project.

    Your other subprojects should be in C:/work/subproject1, C:/work/subproject2 and so on each having their own pom.xml. Then in the main pom.xml you can refer to the other projects in the

    <modules>      
        <module>../subproject1<module>
        <module>../subproject2<module>
    </modules>
    
    0 讨论(0)
  • 2020-12-14 15:33

    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.

    0 讨论(0)
提交回复
热议问题