Maven 2.x and 3.x Site Plugin

site:deploy possibility to choose directory tree when using sub-modules

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Not A Bug
  • Affects Version/s: 2.0-beta-6
  • Fix Version/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

I use Eclipse and my modules (root and submodules) are all at the same level in the directory tree :

[eclipse_workspace]/root
[eclipse_workspace]/sub1
[eclipse_workspace]/sub2

Until the 2.0-beta-5 of the maven site plugin, when I deployed my site, I obtained this tree :

[publish]/root
[publish]/root/sub1
[publish]/root/sub2

I installed the beta-6 version, and the default behaviour has changed, I now have every module at the same level :

[publish]/root
[publish]/sub1
[publish]/sub2

So I just wondered if it was possible to have an option to choose whether we prefer to publish the submodules inside the root directory, or at the same level... ?

thx
Isabelle

Issue Links

Activity

Hide
Benjamin Bentmann added a comment -

I experienced this change, too, but it was not caused by maven-site-plugin:2.0-beta-6 but actually by Maven itself after I updated to 2.0.8. The change is caused by the fix for MNG-3134 where they brought the URL inheritance for the site in line with the other URL inheritance for SCM. In other words, the directory layout of the site resembles the layout of the source repository.

Isabelle, you need not wait for an option to get the old layout back. All that happened is that Maven changed the default handling when inheriting ${project.distributionManagement.site.url}. You can put a <distributionManagement> element in every of your sub POMs to specify the desired location and overwrite the otherwise inherited URL.

Nevertheless, I would appreciate some kind of option like a new POM element, too. Could imagine something like this:

<distributionManagement>
  <site>
    <url>...</url>
    <!-- How shall the URL be adjusted when inherited by sub modules?
         default: As Maven 2.0.8 does, i.e. keep the layout from source repository
         flat:    deploy sub module to same directory as parent
         nested:  deploy sub module immediately into directory of parent
    -->
    <adjustment>default|flat|nested</adjust>
  </site>
</distributionManagement>

This would allow for a central configuration of the site layout and spare one from copy&paste'ing in the sub POMs.

Show
Benjamin Bentmann added a comment - I experienced this change, too, but it was not caused by maven-site-plugin:2.0-beta-6 but actually by Maven itself after I updated to 2.0.8. The change is caused by the fix for MNG-3134 where they brought the URL inheritance for the site in line with the other URL inheritance for SCM. In other words, the directory layout of the site resembles the layout of the source repository. Isabelle, you need not wait for an option to get the old layout back. All that happened is that Maven changed the default handling when inheriting ${project.distributionManagement.site.url}. You can put a <distributionManagement> element in every of your sub POMs to specify the desired location and overwrite the otherwise inherited URL. Nevertheless, I would appreciate some kind of option like a new POM element, too. Could imagine something like this:
<distributionManagement>
  <site>
    <url>...</url>
    <!-- How shall the URL be adjusted when inherited by sub modules?
         default: As Maven 2.0.8 does, i.e. keep the layout from source repository
         flat:    deploy sub module to same directory as parent
         nested:  deploy sub module immediately into directory of parent
    -->
    <adjustment>default|flat|nested</adjust>
  </site>
</distributionManagement>
This would allow for a central configuration of the site layout and spare one from copy&paste'ing in the sub POMs.
Hide
Richard Gomes added a comment - - edited

Hi,

I had a bad time too with this 'issue'/functionality... depending how you need it.
Yes... It would be handy to tell Maven that I use flat project model.

Below you can see how I organized my master POM.

    <!-- This is the master POM -->
    <distributionManagement>
        ...
        <!-- NOTES:
          * maven-site-plugin gets confused by flat project model employed by Eclipse :(
          
          * It's also confused to configure an staging URL because maven-site-plugin takes
             the staging URL from <configuration> and not from <distributionManagement>.
          
          * We circumvented these difficulties by tweaking siteURL depending on a profile.
             So, in order to 'deploy' to a staging server, please define a profile called 
             'staging' in your settings.xml file like shown below:
           
                 <settings>
                    ...
                    <profiles>
                        <profile>
                            <id>staging</id>
                            <properties>
                                <props.site.deploy.url>scp://localhost:/srv/jquantlib.org/sites</props.site.deploy.url>
                            </properties>
                        </profile>
                    </profiles>
                    ...
                 </settings>
           
             You can deploy to a staging server like this:
           
                  mvn clean site-deploy -P staging
           
             The big drawback is that we have only one <site> for 2 purposes, which is not very good :(
             One way to circumvent this problem is deploying via file: protocol to your local web server.
          
          * Every project MUST REDEFINE the <site> section as it is (no modifications are needed!) in order
             to override the way Maven promotes inheritance which supposes a hierarchical model.
        -->
        <site>
            <id>site</id>
            <name>${project.artifactId} site generated by Maven</name>
            <url>${props.site.deploy.url}/${project.artifactId}</url>
        </site>

    </distributionManagement>

... and all projects need to copy/paste the same block

    <-- This is a 'child' project -->
    <distributionManagement>
        <!-- NOTE: <site> entry cannot be inherited.
               It means to say you need to copy/paste this text as it is to all child projects.
               See comments in the parent POM for more information.
          -->
        <site>
            <id>site</id>
            <name>${project.project.artifactId} site generated by Maven</name>
            <url>${props.site.deploy.url}/${project.artifactId}</url>
        </site>
    </distributionManagement>

As you can see, the trick is defining a profile 'staging' in settings.xml:

<settings>
	...
	<profiles>
	<profile>
		<id>staging</id>
		<properties>
		<props.site.deploy.url>file:///srv/jquantlib.org/sites</props.site.deploy.url>
		</properties>
	</profile>
	</profiles>
	...
</settings>

Note: I'm using file: protocol in order to deploy to my local webserver.

And then you can call Maven like this:

mvn clean site-deploy -P staging

You can see these sites published here: http://www.jquantlib.org/sites/

Thanks

Richard Gomes
http://www.jquantlib.org/index.php/User:RichardGomes

Show
Richard Gomes added a comment - - edited Hi, I had a bad time too with this 'issue'/functionality... depending how you need it. Yes... It would be handy to tell Maven that I use flat project model. Below you can see how I organized my master POM.
    <!-- This is the master POM -->
    <distributionManagement>
        ...
        <!-- NOTES:
          * maven-site-plugin gets confused by flat project model employed by Eclipse :(
          
          * It's also confused to configure an staging URL because maven-site-plugin takes
             the staging URL from <configuration> and not from <distributionManagement>.
          
          * We circumvented these difficulties by tweaking siteURL depending on a profile.
             So, in order to 'deploy' to a staging server, please define a profile called 
             'staging' in your settings.xml file like shown below:
           
                 <settings>
                    ...
                    <profiles>
                        <profile>
                            <id>staging</id>
                            <properties>
                                <props.site.deploy.url>scp://localhost:/srv/jquantlib.org/sites</props.site.deploy.url>
                            </properties>
                        </profile>
                    </profiles>
                    ...
                 </settings>
           
             You can deploy to a staging server like this:
           
                  mvn clean site-deploy -P staging
           
             The big drawback is that we have only one <site> for 2 purposes, which is not very good :(
             One way to circumvent this problem is deploying via file: protocol to your local web server.
          
          * Every project MUST REDEFINE the <site> section as it is (no modifications are needed!) in order
             to override the way Maven promotes inheritance which supposes a hierarchical model.
        -->
        <site>
            <id>site</id>
            <name>${project.artifactId} site generated by Maven</name>
            <url>${props.site.deploy.url}/${project.artifactId}</url>
        </site>

    </distributionManagement>
... and all projects need to copy/paste the same block
    <-- This is a 'child' project -->
    <distributionManagement>
        <!-- NOTE: <site> entry cannot be inherited.
               It means to say you need to copy/paste this text as it is to all child projects.
               See comments in the parent POM for more information.
          -->
        <site>
            <id>site</id>
            <name>${project.project.artifactId} site generated by Maven</name>
            <url>${props.site.deploy.url}/${project.artifactId}</url>
        </site>
    </distributionManagement>
As you can see, the trick is defining a profile 'staging' in settings.xml:
<settings>
	...
	<profiles>
	<profile>
		<id>staging</id>
		<properties>
		<props.site.deploy.url>file:///srv/jquantlib.org/sites</props.site.deploy.url>
		</properties>
	</profile>
	</profiles>
	...
</settings>
Note: I'm using file: protocol in order to deploy to my local webserver. And then you can call Maven like this:
mvn clean site-deploy -P staging
You can see these sites published here: http://www.jquantlib.org/sites/ Thanks Richard Gomes http://www.jquantlib.org/index.php/User:RichardGomes
Hide
Lukas Theussl added a comment -

The deploy location is uniquely determined by distMngmnt.site.url, there is a default inheritance mechanism that is used consistently by the site plugin. If you want to avoid duplication, use a default directory layout. If you use a custom layout, don't complain that you have to adjust your build.

Show
Lukas Theussl added a comment - The deploy location is uniquely determined by distMngmnt.site.url, there is a default inheritance mechanism that is used consistently by the site plugin. If you want to avoid duplication, use a default directory layout. If you use a custom layout, don't complain that you have to adjust your build.

People

Vote (5)
Watch (8)

Dates

  • Created:
    Updated:
    Resolved: