SCM URL relative to parent SCM URL in POMs

你离开我真会死。 提交于 2019-12-03 14:15:14

I would have thought that this works:

<scm>
    <connection>${project.parent.scm.connection}/data-model/trunk</connection>
    <developerConnection>${project.parent.scm.developerConnection}/data-model/trunk</developerConnection>
    <url>${project.parent.scm.url}/data-model/trunk</url>
</scm>

If it doesn't, there's still the possibility to assign these values programmatically (I'll use GMaven to do that, but you can also use the antrun plugin or write a custom plugin)

First, set a property

<properties>
    <relativeScmPath>data-model/trunk</relativeScmPath>
</properties>

Then assign a relative offset to all SCM properties:

<plugin>
    <groupId>org.codehaus.gmaven</groupId>
    <artifactId>gmaven-plugin</artifactId>
    <version>1.3</version>
    <executions>
        <execution>
            <id>assign-scm</id>
            <phase>validate</phase>
            <goals>
                <goal>execute</goal>
            </goals>
            <configuration>
                <source>
                <![CDATA[
                def parentScm = project.parent.scm;
                def thisScm = project.scm;
                def relPath = project.properties['relativeScmPath'];
                ['connection','developerConnection','url'].each{
                    thisScm[it] = parentScm[it] + relPath;
                }
                ]]>
                </source>
            </configuration>
        </execution>
    </executions>
</plugin>

You could add this to the root pom and change it so that it runs only if it finds the property, and then you can automatically set the value for n sub modules by simply adding the property to them.

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