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/15 00:34:45 UTC

[maven-doxia-sitetools] branch DOXIASITETOOLS-278 created (now 7e3c970)

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


      at 7e3c970  [DOXIASITETOOLS-278] Remove menu items link in the side bar to sub module that do not generate any site in the same build

This branch includes the following new commits:

     new 7e3c970  [DOXIASITETOOLS-278] Remove menu items link in the side bar to sub module that do not generate any site in the same build

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.



[maven-doxia-sitetools] 01/01: [DOXIASITETOOLS-278] Remove menu items link in the side bar to sub module 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 7e3c97019484fa732270c4b81bd8e1aaea791d9c
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Jan 15 01:34:35 2023 +0100

    [DOXIASITETOOLS-278] Remove menu items link in the side bar to sub module that do not generate any site in the same build
---
 .../apache/maven/doxia/tools/DefaultSiteTool.java  | 58 ++++++++++++++++++++++
 1 file changed, 58 insertions(+)

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 d061b4d..b0cfab7 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,6 +681,17 @@ public class DefaultSiteTool
                     }
                 }
 
+                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" );
+                }
+                if ( "true".equalsIgnoreCase( skipFlag ) )
+                {
+                    continue;
+                }
+
                 String siteUrl = getDistMgmntSiteUrl( moduleProject );
                 String itemName =
                     ( moduleProject.getName() == null ) ? moduleProject.getArtifactId() : moduleProject.getName();
@@ -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 )