Prevent NPE when setting description element

This commit is contained in:
Michael Simacek 2015-03-16 16:47:36 +01:00
parent 22915b1d82
commit ded303602d
3 changed files with 73 additions and 2 deletions

View File

@ -1,7 +1,7 @@
From d4974142b5123f3dbe23ea9ca9399e7f0bc2f99e Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Mon, 16 Mar 2015 14:29:21 +0100
Subject: [PATCH] Avoid duplicate MOJO parameters
Subject: [PATCH 1/2] Avoid duplicate MOJO parameters
---
.../JavaAnnotationsMojoDescriptorExtractor.java | 24 ++++++++++++++++++++--

View File

@ -0,0 +1,66 @@
From 9b30ecf988467f5310ef591f0a9f73ac989bb766 Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Mon, 16 Mar 2015 16:42:20 +0100
Subject: [PATCH 2/2] Deal with nulls from getComment
---
.../annotations/JavaAnnotationsMojoDescriptorExtractor.java | 6 +++---
.../extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
index 7a7e70a..644be12 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
@@ -269,7 +269,7 @@ public class JavaAnnotationsMojoDescriptorExtractor
MojoAnnotationContent mojoAnnotationContent = entry.getValue().getMojo();
if ( mojoAnnotationContent != null )
{
- mojoAnnotationContent.setDescription( javaClass.getComment() );
+ mojoAnnotationContent.setDescription( javaClass.getComment() != null ? javaClass.getComment() : "" );
DocletTag since = findInClassHierarchy( javaClass, "since" );
if ( since != null )
@@ -300,7 +300,7 @@ public class JavaAnnotationsMojoDescriptorExtractor
}
ParameterAnnotationContent parameterAnnotationContent = parameter.getValue();
- parameterAnnotationContent.setDescription( javaField.getComment() );
+ parameterAnnotationContent.setDescription( javaClass.getComment() != null ? javaClass.getComment() : "" );
DocletTag deprecated = javaField.getTagByName( "deprecated" );
if ( deprecated != null )
@@ -326,7 +326,7 @@ public class JavaAnnotationsMojoDescriptorExtractor
}
ComponentAnnotationContent componentAnnotationContent = component.getValue();
- componentAnnotationContent.setDescription( javaField.getComment() );
+ componentAnnotationContent.setDescription( javaClass.getComment() != null ? javaClass.getComment() : "" );
DocletTag deprecated = javaField.getTagByName( "deprecated" );
if ( deprecated != null )
diff --git a/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java b/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java
index 7dbd0ef..1bc0158 100644
--- a/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java
+++ b/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java
@@ -115,7 +115,7 @@ public class JavaJavadocMojoDescriptorExtractor
ExtendedMojoDescriptor mojoDescriptor = new ExtendedMojoDescriptor();
mojoDescriptor.setLanguage( "java" );
mojoDescriptor.setImplementation( javaClass.getFullyQualifiedName() );
- mojoDescriptor.setDescription( javaClass.getComment() );
+ mojoDescriptor.setDescription( javaClass.getComment() != null ? javaClass.getComment() : "" );
// ----------------------------------------------------------------------
// Mojo annotations in alphabetical order
@@ -392,7 +392,7 @@ public class JavaJavadocMojoDescriptorExtractor
pd.setType( type.getFullyQualifiedName() );
- pd.setDescription( field.getComment() );
+ pd.setDescription( javaClass.getComment() != null ? javaClass.getComment() : "" );
DocletTag deprecationTag = field.getTagByName( JavadocMojoAnnotation.DEPRECATED );
--
2.1.0

View File

@ -1,6 +1,6 @@
Name: maven-plugin-tools
Version: 3.4
Release: 1%{?dist}
Release: 2%{?dist}
Epoch: 0
Summary: Maven Plugin Tools
License: ASL 2.0
@ -10,6 +10,7 @@ BuildArch: noarch
Source0: http://repo2.maven.org/maven2/org/apache/maven/plugin-tools/%{name}/%{version}/%{name}-%{version}-source-release.zip
Patch0: 0001-Avoid-duplicate-MOJO-parameters.patch
Patch1: 0002-Deal-with-nulls-from-getComment.patch
BuildRequires: maven-local
BuildRequires: mvn(com.sun:tools)
@ -169,6 +170,7 @@ API documentation for %{name}.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
# For com.sun:tools use scope "compile" instead of "system"
%pom_remove_dep com.sun:tools maven-plugin-tools-javadoc
@ -255,6 +257,9 @@ API documentation for %{name}.
%changelog
* Mon Mar 16 2015 Michael Simacek <msimacek@redhat.com> - 0:3.4-2
- Prevent NPE when setting description element
* Mon Mar 16 2015 Michael Simacek <msimacek@redhat.com> - 0:3.4-1
- Update to upstream version 3.4