Maven - Replace property in project.pom file when installing in repository

北城以北 提交于 2019-12-13 02:16:25

问题


I have a parent project that defines a property, for example:

    <properties>
        <myproject-version>1.0</myproject-version>
    </properties>

In a 'child' project I use

<parent>
    <groupId>com.home</groupId>
    <artifactId>my-modules</artifactId>
    <version>${myproject-version}</version>
</parent>

Everything works nice, but when Maven installs jar in repository, it creates pom like

<parent>
    <groupId>com.home</groupId>
    <artifactId>my-modules</artifactId>
    <version>${myproject-version}</version>
</parent>

And I need that value of my-version to be replaced with 1.0

<parent>
    <groupId>com.home</groupId>
    <artifactId>my-modules</artifactId>
    <version>1.0</version>
</parent>

Is there any way to do that? I need 1.0 because of some compilation problems that occure when other projects use my project as dependency. (They look for a version ${myproject-version} instead of '1.0'


回答1:


Actually, I'm surprised to see this even working. A version must be specified in the parent tag (otherwise there is no way to know which version to pull from the repository) but that version should not be defined in terms of data defined in the parent pom, otherwise an obvious problem occurs: the parent pom would be needed to determine which parent pom is needed.

So I don't think there is any way to do what you are trying to do and, to be honest, I think its a bad idea.



来源:https://stackoverflow.com/questions/2104432/maven-replace-property-in-project-pom-file-when-installing-in-repository

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!