Skip to content

Commit

Permalink
[MSITE-856] - NullPointer on org.apache.maven.plugins.site.render.Sit…
Browse files Browse the repository at this point in the history
…eMap.relativePath

Closes #31
  • Loading branch information
jonvolfson authored and hboutemy committed Jun 21, 2020
1 parent d4160ab commit ec954c8
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 3 deletions.
18 changes: 18 additions & 0 deletions src/it/projects/MSITE-856/invoker.properties
Original file line number Diff line number Diff line change
@@ -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
62 changes: 62 additions & 0 deletions src/it/projects/MSITE-856/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
30 changes: 30 additions & 0 deletions src/it/projects/MSITE-856/src/site/site.xml
Original file line number Diff line number Diff line change
@@ -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>
45 changes: 45 additions & 0 deletions src/it/projects/MSITE-856/verify.bsh
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 7 additions & 3 deletions src/main/java/org/apache/maven/plugins/site/render/SiteMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,13 @@ private static void extractItems( List<MenuItem> items, Sink sink )
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_();
}
Expand Down

0 comments on commit ec954c8

Please sign in to comment.