@@ -329,7 +329,8 @@ public Collection<String> resolveLibrary(@NotNull Library library) {
329
329
*/
330
330
@ Nullable
331
331
protected String resolveSnapshot (@ NotNull String repository , @ NotNull Library library ) {
332
- String url = requireNonNull (repository , "repository" ) + requireNonNull (library , "library" ).getPartialPath () + "maven-metadata.xml" ;
332
+ String mavenMetadata = repository .startsWith ("file" ) ? "maven-metadata-local.xml" : "maven-metadata.xml" ;
333
+ String url = requireNonNull (repository , "repository" ) + requireNonNull (library , "library" ).getPartialPath () + mavenMetadata ;
333
334
try {
334
335
URLConnection connection = new URL (requireNonNull (url , "url" )).openConnection ();
335
336
@@ -372,7 +373,7 @@ protected String getURLFromMetadata(@NotNull InputStream inputStream, @NotNull L
372
373
requireNonNull (inputStream , "inputStream" );
373
374
requireNonNull (library , "library" );
374
375
375
- String timestamp , buildNumber ;
376
+ String version = library . getVersion () ;
376
377
try {
377
378
// This reads the maven-metadata.xml file and gets the snapshot info from the <snapshot> tag.
378
379
// Example tag:
@@ -394,37 +395,42 @@ protected String getURLFromMetadata(@NotNull InputStream inputStream, @NotNull L
394
395
if (snapshot .getNodeType () != Node .ELEMENT_NODE ) {
395
396
return null ;
396
397
}
397
- Node timestampNode = ((Element ) snapshot ).getElementsByTagName ("timestamp" ).item (0 );
398
- if (timestampNode == null || timestampNode .getNodeType () != Node .ELEMENT_NODE ) {
399
- return null ;
400
- }
401
- Node buildNumberNode = ((Element ) snapshot ).getElementsByTagName ("buildNumber" ).item (0 );
402
- if (buildNumberNode == null || buildNumberNode .getNodeType () != Node .ELEMENT_NODE ) {
403
- return null ;
404
- }
405
- Node timestampChild = timestampNode .getFirstChild ();
406
- if (timestampChild == null || timestampChild .getNodeType () != Node .TEXT_NODE ) {
407
- return null ;
408
- }
409
- Node buildNumberChild = buildNumberNode .getFirstChild ();
410
- if (buildNumberChild == null || buildNumberChild .getNodeType () != Node .TEXT_NODE ) {
411
- return null ;
398
+ Node localCopyNode = ((Element ) snapshot ).getElementsByTagName ("localCopy" ).item (0 );
399
+ if (localCopyNode == null || localCopyNode .getNodeType () != Node .ELEMENT_NODE ) {
400
+ // Resolve with snapshot number instead of base name
401
+ Node timestampNode = ((Element ) snapshot ).getElementsByTagName ("timestamp" ).item (0 );
402
+ if (timestampNode == null || timestampNode .getNodeType () != Node .ELEMENT_NODE ) {
403
+ return null ;
404
+ }
405
+ Node buildNumberNode = ((Element ) snapshot ).getElementsByTagName ("buildNumber" ).item (0 );
406
+ if (buildNumberNode == null || buildNumberNode .getNodeType () != Node .ELEMENT_NODE ) {
407
+ return null ;
408
+ }
409
+ Node timestampChild = timestampNode .getFirstChild ();
410
+ if (timestampChild == null || timestampChild .getNodeType () != Node .TEXT_NODE ) {
411
+ return null ;
412
+ }
413
+ Node buildNumberChild = buildNumberNode .getFirstChild ();
414
+ if (buildNumberChild == null || buildNumberChild .getNodeType () != Node .TEXT_NODE ) {
415
+ return null ;
416
+ }
417
+ String timestamp = timestampChild .getNodeValue ();
418
+ String buildNumber = buildNumberChild .getNodeValue ();
419
+
420
+ version = library .getVersion ();
421
+ // Call .substring(...) only on versions ending in "-SNAPSHOT".
422
+ // It should never happen that a snapshot version doesn't end in "-SNAPSHOT", but better be sure
423
+ if (version .endsWith ("-SNAPSHOT" )) {
424
+ version = version .substring (0 , version .length () - "-SNAPSHOT" .length ());
425
+ }
426
+
427
+ version = version + '-' + timestamp + '-' + buildNumber ;
412
428
}
413
- timestamp = timestampChild .getNodeValue ();
414
- buildNumber = buildNumberChild .getNodeValue ();
415
429
} catch (ParserConfigurationException | SAXException e ) {
416
430
logger .debug ("Invalid maven-metadata.xml" , e );
417
431
return null ;
418
432
}
419
-
420
- String version = library .getVersion ();
421
- // Call .substring(...) only on versions ending in "-SNAPSHOT".
422
- // It should never happen that a snapshot version doesn't end in "-SNAPSHOT", but better be sure
423
- if (version .endsWith ("-SNAPSHOT" )) {
424
- version = version .substring (0 , version .length () - "-SNAPSHOT" .length ());
425
- }
426
-
427
- return Util .craftPath (library .getPartialPath (), library .getArtifactId (), version + '-' + timestamp + '-' + buildNumber , library .getClassifier ());
433
+ return Util .craftPath (library .getPartialPath (), library .getArtifactId (), version , library .getClassifier ());
428
434
}
429
435
430
436
/**
0 commit comments