1717import org .apache .maven .artifact .resolver .ArtifactResolutionResult ;
1818import org .apache .maven .artifact .resolver .filter .ExclusionSetFilter ;
1919import org .apache .maven .model .Dependency ;
20+ import org .apache .maven .plugin .logging .Log ;
21+ import org .apache .maven .plugin .logging .SystemStreamLog ;
2022import org .apache .maven .project .MavenProject ;
2123import org .apache .maven .project .artifact .InvalidDependencyVersionException ;
2224import org .apache .maven .project .artifact .MavenMetadataSource ;
@@ -40,6 +42,7 @@ public static Collection<Artifact> resolveTransitively(
4042 artifactFactory , artifactResolver ,
4143 localRepository , artifactMetadataSource ,
4244 dependencies , project ,
45+ new SystemStreamLog (),
4346 null );
4447 }
4548
@@ -49,10 +52,11 @@ public static Collection<Artifact> resolveTransitively(
4952 final ArtifactRepository localRepository ,
5053 final ArtifactMetadataSource artifactMetadataSource ,
5154 final Dependency [] dependencies , final MavenProject project ,
55+ final Log log ,
5256 final String [] artifactExcludes )
5357 throws InvalidDependencyVersionException ,
5458 ArtifactResolutionException , ArtifactNotFoundException {
55- if (dependencies == null ) {
59+ if (dependencies == null || dependencies . length == 0 ) {
5660 return Collections .emptyList ();
5761 }
5862
@@ -74,9 +78,19 @@ public static Collection<Artifact> resolveTransitively(
7478
7579 final ArtifactResolutionResult artifactResolutionResult = artifactResolver .resolve (request );
7680
77- final Set <Artifact > resolvedArtifacts = artifactResolutionResult .getArtifacts ();
78-
79- return resolvedArtifacts ;
81+ if (!artifactResolutionResult .isSuccess ()) {
82+ if (artifactResolutionResult .hasMissingArtifacts ()) {
83+ log .error ("artifactResolutionResult has missing artifacts : " + artifactResolutionResult .getMissingArtifacts ());
84+ throw new RuntimeException ("Artifacts - missing artifacts" );
85+ } else if (artifactResolutionResult .hasExceptions ()) {
86+ log .error ("artifactResolutionResult has exceptions : " + artifactResolutionResult .getExceptions ());
87+ throw new RuntimeException ("Artifacts - exceptions" , artifactResolutionResult .getExceptions ().get (0 ));
88+ } else {
89+ log .error ("artifactResolutionResult status is not success" );
90+ throw new RuntimeException ("Artifacts - not in success" );
91+ }
92+ }
93+ return artifactResolutionResult .getArtifacts ();
8094 }
8195
8296 public static Collection <Artifact > resolve (
@@ -87,7 +101,7 @@ public static Collection<Artifact> resolve(
87101 final Dependency [] dependencies , final MavenProject project )
88102 throws InvalidDependencyVersionException ,
89103 ArtifactResolutionException , ArtifactNotFoundException {
90- if (dependencies == null ) {
104+ if (dependencies == null || dependencies . length == 0 ) {
91105 return Collections .emptyList ();
92106 }
93107
0 commit comments