You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/01/31 15:38:29 UTC

[maven-doxia-sitetools] branch DOXIASITETOOLS-278 updated (65442c0 -> ee8b511)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch DOXIASITETOOLS-278
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git


    omit 65442c0  [DOXIASITETOOLS-278] Remove menu items link in the sidebar to submodule that do not generate any site in the same build
     add 18fd382  [DOXIASITETOOLS-284] Upgrade to Maven Fluido Skin 2.0.0-M2 in default site descriptor
     new ee8b511  [DOXIASITETOOLS-278] Remove menu items link in the sidebar to submodule that do not generate any site in the same build

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (65442c0)
            \
             N -- N -- N   refs/heads/DOXIASITETOOLS-278 (ee8b511)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doxia-integration-tools/src/main/resources/default-site.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[maven-doxia-sitetools] 01/01: [DOXIASITETOOLS-278] Remove menu items link in the sidebar to submodule that do not generate any site in the same build

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch DOXIASITETOOLS-278
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git

commit ee8b5119ea179f45224f15a710a786973a9954a5
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Jan 15 01:34:35 2023 +0100

    [DOXIASITETOOLS-278] Remove menu items link in the sidebar to submodule that do not generate any site in the same build
    
    This closes #78
---
 .../apache/maven/doxia/tools/DefaultSiteTool.java  | 86 ++++++++++++++++++----
 1 file changed, 72 insertions(+), 14 deletions(-)

diff --git a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
index 1ca13bb..17bf7d0 100644
--- a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
+++ b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
@@ -57,6 +57,7 @@ import org.apache.maven.doxia.site.decoration.inheritance.DecorationModelInherit
 import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader;
 import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Writer;
 import org.apache.maven.model.DistributionManagement;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.model.Site;
 import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
@@ -75,6 +76,7 @@ import org.codehaus.plexus.interpolation.MapBasedValueSource;
 import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
 import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource;
 import org.codehaus.plexus.interpolation.RegexBasedInterpolator;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -679,11 +681,19 @@ public class DefaultSiteTool
                     }
                 }
 
-                String siteUrl = getDistMgmntSiteUrl( moduleProject );
+                final String pluginId = "org.apache.maven.plugins:maven-site-plugin";
+                String skipFlag = getPluginParameter( moduleProject, pluginId, "skip" );
+                if ( skipFlag == null )
+                {
+                    skipFlag = moduleProject.getProperties().getProperty( "maven.site.skip" );
+                }
+
+                String siteUrl = "true".equalsIgnoreCase( skipFlag ) ? null : getDistMgmntSiteUrl( moduleProject );
                 String itemName =
                     ( moduleProject.getName() == null ) ? moduleProject.getArtifactId() : moduleProject.getName();
+                String defaultSiteUrl = "true".equalsIgnoreCase( skipFlag ) ? null : moduleProject.getArtifactId();
 
-                appendMenuItem( project, menu, itemName, siteUrl, moduleProject.getArtifactId() );
+                appendMenuItem( project, menu, itemName, siteUrl, defaultSiteUrl );
             }
         }
         else if ( decorationModel.getMenuRef( "modules" ).getInherit() == null )
@@ -1350,7 +1360,7 @@ public class DefaultSiteTool
      * @param menu not null
      * @param name not null
      * @param href could be null
-     * @param defaultHref not null
+     * @param defaultHref could be null
      */
     private void appendMenuItem( MavenProject project, Menu menu, String name, String href, String defaultHref )
     {
@@ -1364,19 +1374,22 @@ public class DefaultSiteTool
         MenuItem item = new MenuItem();
         item.setName( name );
 
-        String baseUrl = getDistMgmntSiteUrl( project );
-        if ( baseUrl != null )
+        if ( selectedHref != null )
         {
-            selectedHref = getRelativePath( selectedHref, baseUrl );
-        }
+            String baseUrl = getDistMgmntSiteUrl( project );
+            if ( baseUrl != null )
+            {
+                selectedHref = getRelativePath( selectedHref, baseUrl );
+            }
 
-        if ( selectedHref.endsWith( "/" ) )
-        {
-            item.setHref( selectedHref + "index.html" );
-        }
-        else
-        {
-            item.setHref( selectedHref + "/index.html" );
+            if ( selectedHref.endsWith( "/" ) )
+            {
+                item.setHref( selectedHref + "index.html" );
+            }
+            else
+            {
+                item.setHref( selectedHref + "/index.html" );
+            }
         }
         menu.addItem( item );
     }
@@ -1446,6 +1459,51 @@ public class DefaultSiteTool
         return null;
     }
 
+    /**
+     * @param project the project
+     * @param pluginId The id of the plugin
+     * @return The information about the plugin.
+     */
+    private static Plugin getPlugin( MavenProject project, String pluginId )
+    {
+        if ( ( project.getBuild() == null ) || ( project.getBuild().getPluginsAsMap() == null ) )
+        {
+            return null;
+        }
+
+        Plugin plugin = project.getBuild().getPluginsAsMap().get( pluginId );
+
+        if ( ( plugin == null ) && ( project.getBuild().getPluginManagement() != null )
+            && ( project.getBuild().getPluginManagement().getPluginsAsMap() != null ) )
+        {
+            plugin = project.getBuild().getPluginManagement().getPluginsAsMap().get( pluginId );
+        }
+
+        return plugin;
+    }
+
+    /**
+     * @param project the project
+     * @param pluginId The pluginId
+     * @param param The child which should be checked.
+     * @return The value of the dom tree.
+     */
+    private static String getPluginParameter( MavenProject project, String pluginId, String param )
+    {
+        Plugin plugin = getPlugin( project, pluginId );
+        if ( plugin != null )
+        {
+            Xpp3Dom xpp3Dom = (Xpp3Dom) plugin.getConfiguration();
+            if ( xpp3Dom != null && xpp3Dom.getChild( param ) != null
+                && StringUtils.isNotEmpty( xpp3Dom.getChild( param ).getValue() ) )
+            {
+                return xpp3Dom.getChild( param ).getValue();
+            }
+        }
+
+        return null;
+    }
+
     private static String urlEncode( final String url )
     {
         if ( url == null )