You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/06/21 11:16:53 UTC

[maven-site-plugin] 01/01: [MSITE-856] - NullPointer on org.apache.maven.plugins.site.render.SiteMap.relativePath

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

slachiewicz pushed a commit to branch MSITE-856
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit d87e73c13a8d65c737631feed49540d33ab73d66
Author: jonvolfson <jo...@yahoo.com>
AuthorDate: Tue Jun 2 15:42:39 2020 -0400

    [MSITE-856] - NullPointer on org.apache.maven.plugins.site.render.SiteMap.relativePath
    
    Closes #31
---
 src/it/projects/MSITE-856/invoker.properties       | 18 +++++++
 src/it/projects/MSITE-856/pom.xml                  | 62 ++++++++++++++++++++++
 src/it/projects/MSITE-856/src/site/site.xml        | 30 +++++++++++
 src/it/projects/MSITE-856/verify.bsh               | 45 ++++++++++++++++
 .../apache/maven/plugins/site/render/SiteMap.java  | 10 ++--
 5 files changed, 162 insertions(+), 3 deletions(-)

diff --git a/src/it/projects/MSITE-856/invoker.properties b/src/it/projects/MSITE-856/invoker.properties
new file mode 100644
index 0000000..c315ac8
--- /dev/null
+++ b/src/it/projects/MSITE-856/invoker.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.goals=clean install site
\ No newline at end of file
diff --git a/src/it/projects/MSITE-856/pom.xml b/src/it/projects/MSITE-856/pom.xml
new file mode 100644
index 0000000..dfdeccb
--- /dev/null
+++ b/src/it/projects/MSITE-856/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>msite856</groupId>
+  <artifactId>nullcheck</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+  <name>MSITE-856</name>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-site-plugin</artifactId>
+          <version>@project.version@</version>
+          <configuration>
+            <generateSitemap>true</generateSitemap>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+        <version>2.3.1</version>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>index</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+
+</project>
diff --git a/src/it/projects/MSITE-856/src/site/site.xml b/src/it/projects/MSITE-856/src/site/site.xml
new file mode 100644
index 0000000..88a1a95
--- /dev/null
+++ b/src/it/projects/MSITE-856/src/site/site.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.6.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/DECORATION/1.6.0 http://maven.apache.org/xsd/decoration-1.6.0.xsd">
+  <body>
+    <menu name="My Menu">
+      <item name="My first item"/>
+    </menu>
+  </body>
+</project>
diff --git a/src/it/projects/MSITE-856/verify.bsh b/src/it/projects/MSITE-856/verify.bsh
new file mode 100644
index 0000000..802eae9
--- /dev/null
+++ b/src/it/projects/MSITE-856/verify.bsh
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.*;
+import org.codehaus.plexus.util.*;
+
+try
+{
+    final File siteDirectory = new File( basedir, "target/generated-site" );
+    if ( !siteDirectory.exists() || !siteDirectory.isDirectory() )
+    {
+        System.err.println( "generated-site is missing or not a directory." );
+        return false;
+    }
+
+    File index = new File( siteDirectory, "xdoc/sitemap.xml" );
+    if ( !index.exists() || index.isDirectory() )
+    {
+        System.err.println( "no sitemap.xml!" );
+        return false;
+    }
+}
+catch ( IOException e )
+{
+    e.printStackTrace();
+    return false;
+}
+
+return true;
diff --git a/src/main/java/org/apache/maven/plugins/site/render/SiteMap.java b/src/main/java/org/apache/maven/plugins/site/render/SiteMap.java
index 85ccc61..d454170 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/SiteMap.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/SiteMap.java
@@ -172,9 +172,13 @@ public class SiteMap
         for ( MenuItem item : items )
         {
             sink.listItem();
-            sink.link( relativePath( item.getHref() ) );
-            sink.text( item.getName() );
-            sink.link_();
+            if ( item.getHref() != null )
+            {
+                sink.link( relativePath( item.getHref() ) );
+                sink.text( item.getName() );
+                sink.link_();
+            }
+
             extractItems( item.getItems(), sink );
             sink.listItem_();
         }