2

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?

Jean-Rémy Revy
  • 5,607
  • 3
  • 39
  • 65
Greg
  • 41
  • 4
  • I would suggest to use staging-site instead of this construction, cause Maven's ideas to have separation between released and stages sites but not between released and SNAPSHOT sites. – khmarbaise Aug 08 '11 at 08:33
  • Thanks for the suggestion. This appears to solve half my problem, in that the parent link from the child project is correct when deployed through staging as well as normally without profiles. However, the problem of modifying arbitrary text and links on the site would still require changing properties somehow (since profiles don't seem to be working for site generation). – Greg Aug 10 '11 at 02:55

0 Answers0