Maven站点插件可以单独部署快照和发布吗?

发布于 2024-11-28 12:12:36 字数 2646 浏览 2 评论 0原文

我想为 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 版站点插件,这对于父站点来说效果很好,但即使指定的发布配置文件处于活动状态,所有后代站点也会恢复到快照或“dev”版本。使用 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,我可以看到配置文件属性已正确应用,但站点插件似乎忽略了这一点。

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

I would like to deploy a site for a hierarchy of Maven projects differently for snapshots and releases (i.e. http://example.org for releases and http://dev.example.org for snapshots) and keep the project hierarchy (parents, children, modules) correct with proper links.

My attempt was to assign properties to hold the "current" site information as well as properties to hold each possible type of site (i.e. dev, stable, etc.). I would then use a profile to switch the site info at release time. The following is an example of what I mean.

Parent POM snippet:

<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>

Example parent site descriptor:

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

Example child site descriptor:

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

The distribution management part of this works perfectly and deploys the files as I would expect (to the proper directory on the target machine based on the active profile).

For the actual site part:

With version 2.2 of the site plugin, this works fine for the parent site, but all descendant sites revert back to the snapshot or "dev" version even when the release profile specified is active. With version 3.0 of the site plugin, the following message is printed and (as stated) no parent menu is created. The links section acts like version 2.2.

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

Using the properties-maven-plugin from codehaus, I am able to see that the profile properties are applied correctly, but the site plugin seems to ignore this.

Is there a better way to accomplish what I am trying to do? Is this a bug, or have I made a mistake somewhere?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文