Maven 2.x and 3.x Site Plugin

Links in site.xml get translated to ../../../

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: 2.0-beta-5
  • Fix Version/s: None
  • Component/s: relative links
  • Labels:
    None
  • Environment:
    Linux FC6 Sun Java (build 1.5.0_10-b03, mixed mode, sharing)
  • Number of attachments :
    1

Description

In Site.xml for a project (that has a parent POM)

<links>
<item name="SIRD Site" href="http://sirdsite.dsths.ad.dstcorp.net/" />
<item name="Apache" href="http://www.apache.org/" />
<item name="Maven 2" href="http://maven.apache.org/maven2/"/>
</links>

Gets rendered as

<div class="xright"> <a href="../../../">SIRD Site</a>

<a href="http://www.apache.org/">Apache</a>

<a href="http://maven.apache.org/maven2/">Maven 2</a>

" http://sirdsite.dsths.ad.dstcorp.net/" != "../../.."

Issue Links

Activity

Hide
Mykel Alvis added a comment -

When I change the hostname to it's IP address, it works.

Show
Mykel Alvis added a comment - When I change the hostname to it's IP address, it works.
Hide
Dennis Lundberg added a comment -

This happens because the site plugin tries to make all URLs relative, when possible. I think that you have something like this defined in the pom.xml for this project:

<url>http://sirdsite.dsths.ad.dstcorp.net/x/y/z/</url>

where x, y and z are some directory names.

Show
Dennis Lundberg added a comment - This happens because the site plugin tries to make all URLs relative, when possible. I think that you have something like this defined in the pom.xml for this project: <url>http://sirdsite.dsths.ad.dstcorp.net/x/y/z/</url> where x, y and z are some directory names.
Hide
John Allen added a comment -

It would be helpful if you could provide the URL that this project says it will be deployed to. This URL is then used to determine if there are any relative paths that will get to links specified in the site.xml.

Show
John Allen added a comment - It would be helpful if you could provide the URL that this project says it will be deployed to. This URL is then used to determine if there are any relative paths that will get to links specified in the site.xml.
Hide
Mykel Alvis added a comment - - edited

For the most recent one:
<site>
<id>sites</id>
<url>scp://sirdsite.dsths.ad.dstcorp.net/var/www/html/maven2-sites/common/ConstraintEngine-1.0.6-SNAPSHOT</url>
</site>

Actually, I sort of worked this one out for myself. The problem, I think, was that I was deploying to a host alias and referencing a FQDN in a link (or vice versa). Things got a little confusing when I tried to view the generated site documentation off the filesystem (oops). Since I now deploy all sites to a standardized location and all URLs are standardized to reference that location, it all works.
I think the issue I really had wasn't that it didn't work but rather that it violates the Principle of Least Astonishment.
This may be the right way to handle this, although based on my minor experience with multi-module builds it's probably designed to handle those cases specifically (I guess?).

I now understand the issue and have been able to provide appropriate changes to my poms to conform to "The Way" and the dependencies report produces the correct links to our internal sites.

Perhaps the thing that is needed the most is a bit of documentation that explains actually what transpires within the site generation process? I would be happy to write that documentation but I don't actually know for sure exactly what happens, although I do seem to know a bit more than I did a couple of months ago.

What else can I do to help?

Show
Mykel Alvis added a comment - - edited For the most recent one: <site> <id>sites</id> <url>scp://sirdsite.dsths.ad.dstcorp.net/var/www/html/maven2-sites/common/ConstraintEngine-1.0.6-SNAPSHOT</url> </site> Actually, I sort of worked this one out for myself. The problem, I think, was that I was deploying to a host alias and referencing a FQDN in a link (or vice versa). Things got a little confusing when I tried to view the generated site documentation off the filesystem (oops). Since I now deploy all sites to a standardized location and all URLs are standardized to reference that location, it all works. I think the issue I really had wasn't that it didn't work but rather that it violates the Principle of Least Astonishment. This may be the right way to handle this, although based on my minor experience with multi-module builds it's probably designed to handle those cases specifically (I guess?). I now understand the issue and have been able to provide appropriate changes to my poms to conform to "The Way" and the dependencies report produces the correct links to our internal sites. Perhaps the thing that is needed the most is a bit of documentation that explains actually what transpires within the site generation process? I would be happy to write that documentation but I don't actually know for sure exactly what happens, although I do seem to know a bit more than I did a couple of months ago. What else can I do to help?
Hide
John Allen added a comment -

Love the 'Principle of Least Astonishment' reference. Yes you're right that this feature was designed primarily to enable the relocation of maven sites without having to regenerate them with new POM defined URLs. Also worthy of note is that you can not reliable use ${expressions} in the POM project.URL as site has to look up and down the project hierarchy (parent and module links) and when building without a reactor (ie you're only building a child project on its own not the entire hierarchy) one can not always get the 'cooked' (interpolated) versions of these POM files and will thus have URLs containing the uninterpolated ${} values. Solution to that is to always use the complete project hierarchy in a reactor build to generate a site. Anyway I digress.

I guess this was always intended for links to maven generated pages so maybe we could, and we should defer to brett here, modify the site.xml link element to support a new attribute that indicates that a link should not be resolved to a relative URL? A more drastic solution would be to provide a site mojo configuration option to disbale relatives altogether but then you;d be kicking yourself when you needed to relocate someone else's mirrored site.

In terms of the docs, by all means please supply a patch to the site pages for the plugin, maybe something in the FAQ or in the examples. It's always good to make folk aware of the behaviour of the system

By the way, there is a site:stage mojo that will lay the site out (deploy) to a local folder on your machine so you can test the resulting generated site out without having to deploy it to its real location. This mojo also supports a deploy option (see docs) which will then deploy that 'staged' site to a remote location allowing you to share the 'staged' site with others via HTTP.

Show
John Allen added a comment - Love the 'Principle of Least Astonishment' reference. Yes you're right that this feature was designed primarily to enable the relocation of maven sites without having to regenerate them with new POM defined URLs. Also worthy of note is that you can not reliable use ${expressions} in the POM project.URL as site has to look up and down the project hierarchy (parent and module links) and when building without a reactor (ie you're only building a child project on its own not the entire hierarchy) one can not always get the 'cooked' (interpolated) versions of these POM files and will thus have URLs containing the uninterpolated ${} values. Solution to that is to always use the complete project hierarchy in a reactor build to generate a site. Anyway I digress. I guess this was always intended for links to maven generated pages so maybe we could, and we should defer to brett here, modify the site.xml link element to support a new attribute that indicates that a link should not be resolved to a relative URL? A more drastic solution would be to provide a site mojo configuration option to disbale relatives altogether but then you;d be kicking yourself when you needed to relocate someone else's mirrored site. In terms of the docs, by all means please supply a patch to the site pages for the plugin, maybe something in the FAQ or in the examples. It's always good to make folk aware of the behaviour of the system By the way, there is a site:stage mojo that will lay the site out (deploy) to a local folder on your machine so you can test the resulting generated site out without having to deploy it to its real location. This mojo also supports a deploy option (see docs) which will then deploy that 'staged' site to a remote location allowing you to share the 'staged' site with others via HTTP.
Hide
Dennis Lundberg added a comment -

I have added an FAQ entry for this.

Show
Dennis Lundberg added a comment - I have added an FAQ entry for this.
Hide
Mike Hanafey added a comment -

I ran into the "URLs containing uninterpolated ${}" digression in John's comment 2 hops above. In my case it was a failure to expand a property defined in settings.xml, and in this case it is not clear why this expansion is not done when the child site is generated by itself. Before reading this I had opened http://jira.codehaus.org/browse/MSITE-310.

Now I see it is a known issue, but it does seem like a reasonable idea to put the deployment location in settings.xml, and there should be no issue with the context this property needs to be resolved from.

Show
Mike Hanafey added a comment - I ran into the "URLs containing uninterpolated ${}" digression in John's comment 2 hops above. In my case it was a failure to expand a property defined in settings.xml, and in this case it is not clear why this expansion is not done when the child site is generated by itself. Before reading this I had opened http://jira.codehaus.org/browse/MSITE-310. Now I see it is a known issue, but it does seem like a reasonable idea to put the deployment location in settings.xml, and there should be no issue with the context this property needs to be resolved from.

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: