64
64
import org .eclipse .aether .installation .InstallRequest ;
65
65
import org .eclipse .aether .installation .InstallationException ;
66
66
import org .eclipse .aether .repository .RemoteRepository ;
67
+ import org .eclipse .aether .resolution .ArtifactResolutionException ;
67
68
import org .eclipse .aether .resolution .ArtifactResult ;
68
69
import org .eclipse .aether .resolution .DependencyResult ;
69
70
import org .eclipse .aether .util .ChecksumUtils ;
@@ -236,7 +237,7 @@ public boolean copy(Collection<Artifact> artifacts, Consumer<Collection<Artifact
236
237
}
237
238
238
239
@ Override
239
- public boolean copyAll (
240
+ public boolean copyTransitive (
240
241
ResolutionScope resolutionScope ,
241
242
Collection <ResolutionRoot > resolutionRoots ,
242
243
Consumer <Collection <Artifact >> consumer ,
@@ -352,14 +353,51 @@ public boolean recordStop(Output output) {
352
353
353
354
@ Override
354
355
public boolean resolve (
356
+ Collection <Artifact > artifacts , boolean sources , boolean javadoc , boolean signature , Output output ) {
357
+ try {
358
+ output .verbose ("Resolving {}" , artifacts );
359
+ toolboxResolver .resolveArtifacts (artifacts );
360
+ if (sources || javadoc || signature ) {
361
+ HashSet <Artifact > subartifacts = new HashSet <>();
362
+ artifacts .forEach (a -> {
363
+ if (sources && a .getClassifier ().isEmpty ()) {
364
+ subartifacts .add (new SubArtifact (a , "sources" , "jar" ));
365
+ }
366
+ if (javadoc && a .getClassifier ().isEmpty ()) {
367
+ subartifacts .add (new SubArtifact (a , "javadoc" , "jar" ));
368
+ }
369
+ if (signature && !a .getExtension ().endsWith (".asc" )) {
370
+ subartifacts .add (new SubArtifact (a , "*" , "*.asc" ));
371
+ }
372
+ });
373
+ if (!subartifacts .isEmpty ()) {
374
+ output .verbose ("Resolving (best effort) {}" , subartifacts );
375
+ try {
376
+ toolboxResolver .resolveArtifacts (subartifacts );
377
+ } catch (ArtifactResolutionException e ) {
378
+ // ignore, this is "best effort"
379
+ }
380
+ }
381
+ }
382
+ return true ;
383
+ } catch (Exception e ) {
384
+ throw new RuntimeException (e );
385
+ }
386
+ }
387
+
388
+ @ Override
389
+ public boolean resolveTransitive (
355
390
ResolutionScope resolutionScope ,
356
391
Collection <ResolutionRoot > resolutionRoots ,
357
392
boolean sources ,
358
393
boolean javadoc ,
359
- boolean signatures ,
394
+ boolean signature ,
360
395
Output output ) {
361
396
try {
397
+ int totalArtifactCount = 0 ;
398
+ long totalArtifactSize = 0 ;
362
399
for (ResolutionRoot resolutionRoot : resolutionRoots ) {
400
+ output .verbose ("Resolving {}" , resolutionRoot .getArtifact ());
363
401
DependencyResult dependencyResult = toolboxResolver .resolve (
364
402
resolutionScope ,
365
403
resolutionRoot .getArtifact (),
@@ -375,28 +413,34 @@ public boolean resolve(
375
413
artifactResult .getArtifact ().getFile ());
376
414
}
377
415
}
378
- output .normal ("Resolved: {}" , resolutionRoot .getArtifact ());
379
- if (output .isVerbose ()) {
380
- output .verbose (
381
- " Transitive hull count: {}" ,
382
- dependencyResult .getArtifactResults ().size ());
383
- output .verbose (
384
- " Transitive hull size: {}" ,
385
- humanReadableByteCountBin (dependencyResult .getArtifactResults ().stream ()
386
- .map (ArtifactResult ::getArtifact )
387
- .map (Artifact ::getFile )
388
- .filter (Objects ::nonNull )
389
- .map (f -> {
390
- try {
391
- return Files .size (f .toPath ());
392
- } catch (IOException e ) {
393
- throw new RuntimeException (e );
394
- }
395
- })
396
- .collect (Collectors .summarizingLong (Long ::longValue ))
397
- .getSum ()));
398
- }
416
+ int artifactCount = dependencyResult .getArtifactResults ().size ();
417
+ long artifactSize = dependencyResult .getArtifactResults ().stream ()
418
+ .map (ArtifactResult ::getArtifact )
419
+ .map (Artifact ::getFile )
420
+ .filter (Objects ::nonNull )
421
+ .map (f -> {
422
+ try {
423
+ return Files .size (f .toPath ());
424
+ } catch (IOException e ) {
425
+ throw new RuntimeException (e );
426
+ }
427
+ })
428
+ .collect (Collectors .summarizingLong (Long ::longValue ))
429
+ .getSum ();
430
+ totalArtifactCount += artifactCount ;
431
+ totalArtifactSize += artifactSize ;
432
+
433
+ output .normal (
434
+ "Resolved: {} (count: {}, size: {})" ,
435
+ resolutionRoot .getArtifact (),
436
+ artifactCount ,
437
+ humanReadableByteCountBin (artifactSize ));
399
438
}
439
+ output .normal (
440
+ "Total resolved: {} (count: {}, size: {})" ,
441
+ resolutionRoots .size (),
442
+ totalArtifactCount ,
443
+ humanReadableByteCountBin (totalArtifactSize ));
400
444
return true ;
401
445
} catch (Exception e ) {
402
446
throw new RuntimeException (e );
0 commit comments