diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java index bdb4532a54..c00628319c 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java @@ -63,7 +63,7 @@ public class DefaultMavenExecutionResult public List getTopologicallySortedProjects() { - return topologicallySortedProjects; + return null == topologicallySortedProjects ? Collections. emptyList() : topologicallySortedProjects; } public DependencyResolutionResult getDependencyResolutionResult() diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java index 15ce3e75d1..dd0466567a 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java @@ -33,6 +33,10 @@ public interface MavenExecutionResult MavenProject getProject(); MavenExecutionResult setTopologicallySortedProjects( List projects ); + + /** + * @return the sorted list, or an empty list if there are no projects. + */ List getTopologicallySortedProjects(); MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult result ); diff --git a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java index 99d55eafba..698c6d1514 100644 --- a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java +++ b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java @@ -19,6 +19,10 @@ package org.apache.maven.execution; * under the License. */ +import org.apache.maven.project.MavenProject; + +import java.util.List; + import junit.framework.TestCase; /** @@ -35,5 +39,14 @@ public class DefaultMavenExecutionTest assertNotNull( copy ); assertNotSame( copy, original ); } + + public void testResultWithNullTopologicallySortedProjectsIsEmptyList() + { + MavenExecutionResult result = new DefaultMavenExecutionResult(); + result.setTopologicallySortedProjects( null ); + List projects = result.getTopologicallySortedProjects(); + assertNotNull( projects ); + assertTrue( projects.isEmpty() ); + } }