Skip to content

Commit

Permalink
Fix mojohaus#358 NPE on site generation caused by null returned by de…
Browse files Browse the repository at this point in the history
…precated MavenProject.getDependencyArtifacts()
  • Loading branch information
Wych-Dev committed Apr 12, 2020
1 parent 05905d6 commit 9ed4d9f
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/main/java/org/codehaus/mojo/license/utils/MojoHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class MojoHelper
* @param includes the includes of the resource
* @return {@code true} if the resources was added (not already existing)
*/
public static boolean addResourceDir ( File dir, MavenProject project, String... includes )
public static boolean addResourceDir( File dir, MavenProject project, String... includes )
{
List<?> resources = project.getResources ();
return addResourceDir ( dir, project, resources, includes );
Expand All @@ -71,7 +71,7 @@ public static boolean addResourceDir ( File dir, MavenProject project, String...
* @param includes includes of the new resources
* @return {@code true} if the resource was added (not already existing)
*/
public static boolean addResourceDir ( File dir, MavenProject project, List<?> resources, String... includes )
public static boolean addResourceDir( File dir, MavenProject project, List<?> resources, String... includes )
{
String newresourceDir = dir.getAbsolutePath ();
boolean shouldAdd = true;
Expand Down Expand Up @@ -109,14 +109,14 @@ public static boolean addResourceDir ( File dir, MavenProject project, List<?> r
return shouldAdd;
}

public static Comparator<MavenProject> newMavenProjectComparator ()
public static Comparator<MavenProject> newMavenProjectComparator()
{
return new Comparator<MavenProject> ()
{
/**
* {@inheritDoc}
*/
public int compare ( MavenProject o1, MavenProject o2 )
public int compare( MavenProject o1, MavenProject o2 )
{

String id1 = getArtifactId ( o1.getArtifact () );
Expand All @@ -127,14 +127,14 @@ public int compare ( MavenProject o1, MavenProject o2 )

}

public static Comparator<MavenProject> newMavenProjectComparatorByName ()
public static Comparator<MavenProject> newMavenProjectComparatorByName()
{
return new Comparator<MavenProject> ()
{
/**
* {@inheritDoc}
*/
public int compare ( MavenProject o1, MavenProject o2 )
public int compare( MavenProject o1, MavenProject o2 )
{

String id1 = getProjectName ( o1 );
Expand All @@ -151,17 +151,17 @@ public int compare ( MavenProject o1, MavenProject o2 )
protected static final String[] TIME_UNITES =
{ "ns", "ms", "s", "m", "h", "d" };

public static String convertTime ( long value )
public static String convertTime( long value )
{
return convert ( value, TIME_FACTORS, TIME_UNITES );
}

public static String convert ( long value, double[] factors, String[] unites )
public static String convert( long value, double[] factors, String[] unites )
{
long sign = value == 0 ? 1 : value / Math.abs ( value );
int i = 0;
double tmp = Math.abs ( value );
while ( i < factors.length && i < unites.length && tmp > factors[i] )
while (i < factors.length && i < unites.length && tmp > factors[i])
{
tmp = tmp / factors[i++];
}
Expand All @@ -179,7 +179,7 @@ public static String convert ( long value, double[] factors, String[] unites )
* @param suffix suffix to add
* @return the new url
*/
public static URL getUrl ( URL baseUrl, String suffix )
public static URL getUrl( URL baseUrl, String suffix )
{
String url = baseUrl.toString () + "/" + suffix;
try
Expand All @@ -192,7 +192,7 @@ public static URL getUrl ( URL baseUrl, String suffix )
}
}

public static String getArtifactId ( Artifact artifact )
public static String getArtifactId( Artifact artifact )
{
StringBuilder sb = new StringBuilder ();
sb.append ( artifact.getGroupId () );
Expand All @@ -203,7 +203,7 @@ public static String getArtifactId ( Artifact artifact )
return sb.toString ();
}

public static String getArtifactName ( MavenProject project )
public static String getArtifactName( MavenProject project )
{
StringBuilder sb = new StringBuilder ();
if ( project.getName ().startsWith ( "Unnamed -" ) )
Expand All @@ -230,7 +230,7 @@ public static String getArtifactName ( MavenProject project )
return sb.toString ();
}

public static String getProjectName ( MavenProject project )
public static String getProjectName( MavenProject project )
{
String sb;
if ( project.getName ().startsWith ( "Unnamed" ) )
Expand All @@ -247,7 +247,7 @@ public static String getProjectName ( MavenProject project )
return sb;
}

public static List<String> getParams ( String params )
public static List<String> getParams( String params )
{
String[] split = params == null ? new String[0] : params.split ( "," );
return Arrays.asList ( split );
Expand All @@ -265,7 +265,7 @@ public static List<String> getParams ( String params )
* @param project the MavenProject to retrieve artifacts from
* @return a HashSet of dependencies or an empty set
*/
public static Set<Artifact> getDependencyArtifacts ( MavenProject project )
public static Set<Artifact> getDependencyArtifacts( MavenProject project )
{
if ( project == null || project.getDependencyArtifacts () == null )
{
Expand Down

0 comments on commit 9ed4d9f

Please sign in to comment.