Usage of maven ${basedir} in multi-module setup

后端 未结 2 1980
我在风中等你
我在风中等你 2021-02-03 19:12

I am using a local repository as described in Maven: add a dependency to a jar by relative path.

The repository-url is defined in the topmost pom.xml as

相关标签:
2条回答
  • 2021-02-03 19:35

    How about having multiple repos?

    <repositories>
        <repository>
            <id>ibm-jars-bundle-lv0</id>
            <url>file://${basedir}/ibm-jars-bundle/repo</url>
        </repository>
        <repository>
            <id>ibm-jars-bundle-lv1</id>
            <url>file://${basedir}/../ibm-jars-bundle/repo</url>
        </repository>
        <repository>
            <id>ibm-jars-bundle-lv2</id>
            <url>file://${basedir}/../../ibm-jars-bundle/repo</url>
        </repository>
    </repositories>
    
    0 讨论(0)
  • 2021-02-03 19:45

    Although it is annoying in your case, this is well-known and intentional. A maven project should know about its execution directory only, no matter in what context it is executed.

    I asked almost the same question: Maven variable for reactor root earlier, and the only answer that made sense was to use ${user.dir}, although it's hacky and will not work if you build from a module directory.

    (There is also this very verbose solution: Maven2 property that indicates the parent directory)

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