2

我想为快照和发布以不同的方式为 Maven 项目的层次结构部署一个站点(即http://example.org用于发布,http://dev.example.org用于快照)并保持项目层次结构(父母,孩子,模块)正确的链接。

我的尝试是分配属性来保存“当前”站点信息以及属性来保存每种可能的站点类型(即开发、稳定等)。然后我会使用配置文件在发布时切换站点信息。以下是我的意思的一个例子。

父 POM 片段:

<project>
...

    <url>http://${site.host}/</url>

    <properties>
        <site.host.stable>example.org</site.host.stable>
        <site.host.stable.desc>PARENT-STABLE</site.host.stable.desc>

        <site.host.dev>dev.example.org</site.host.dev>
        <site.host.dev.desc>PARENT-DEV</site.host.dev.desc>

        <site.host>${site.host.dev}</site.host>
        <site.host.other>${site.host.stable}</site.host.other>
        <site.host.other.desc>${site.host.stable.desc}</site.host.other.desc>
    </properties>

    <distributionManagement>
        <site>
            <id>site-deploy-id</id>
            <url>.../var/www/${site.host}</url>
        </site>
    </distributionManagement>

    <profiles>
        <profile>
            <id>example-release</id>
            <properties>
                <site.host>${site.host.stable}</site.host>
                <site.host.other>${site.host.dev}</site.host.other>
                <site.host.other.desc>${site.host.dev.desc}</site.host.other.desc>
            </properties>
        </profile>
    </profiles>

...
</project>

示例父站点描述符:

<project>
    <body>
        <links>
            <item name="${site.host.other.desc}" href="http://${site.host.other}" />
        </links>
    </body>
</project>

示例子站点描述符:

<project>
    <body>
        <menu ref="parent"/>
    </body>
</project>

它的分发管理部分完美地工作并按照我的预期部署文件(基于活动配置文件到目标机器上的正确目录)。

对于实际站点部分:

使用 2.2 版的站点插件,这对父站点运行良好,但即使指定的发布配置文件处于活动状态,所有后代站点也会恢复为快照或“开发”版本。使用 3.0 版的站点插件,将打印以下消息并且(如所述)不创建父菜单。链接部分的行为类似于 2.2 版。

[WARNING] Unable to find a URL to the parent project. The parent menu will NOT be added.

使用 codehaus 的 properties-maven-plugin,我可以看到配置文件属性已正确应用,但站点插件似乎忽略了这一点。

有没有更好的方法来完成我想做的事情?这是一个错误,还是我在某个地方犯了错误?

4

0 回答 0