@@ -235,7 +235,7 @@ private List<Pom> getAncestryWithinProject(Pom projectPom, Map<Path, Pom> projec
235235 .normalize ();
236236 Pom parentPom = projectPoms .get (parentPath );
237237 return parentPom != null && parentPom .getGav ().getGroupId ().equals (parent .getGav ().getGroupId ()) &&
238- parentPom .getGav ().getArtifactId ().equals (parent .getGav ().getArtifactId ()) ? parentPom : null ;
238+ parentPom .getGav ().getArtifactId ().equals (parent .getGav ().getArtifactId ()) ? parentPom : null ;
239239 }
240240
241241 public MavenMetadata downloadMetadata (GroupArtifact groupArtifact , @ Nullable ResolvedPom containingPom , List <MavenRepository > repositories ) throws MavenDownloadingException {
@@ -275,9 +275,9 @@ public MavenMetadata downloadMetadata(GroupArtifactVersion gav, @Nullable Resolv
275275 try {
276276 String scheme = URI .create (repo .getUri ()).getScheme ();
277277 String baseUri = repo .getUri () + (repo .getUri ().endsWith ("/" ) ? "" : "/" ) +
278- requireNonNull (gav .getGroupId ()).replace ('.' , '/' ) + '/' +
279- gav .getArtifactId () + '/' +
280- (gav .getVersion () == null || NAMED_VERSIONS .contains (gav .getVersion ().toUpperCase ()) ? "" : gav .getVersion () + '/' );
278+ requireNonNull (gav .getGroupId ()).replace ('.' , '/' ) + '/' +
279+ gav .getArtifactId () + '/' +
280+ (gav .getVersion () == null || NAMED_VERSIONS .contains (gav .getVersion ().toUpperCase ()) ? "" : gav .getVersion () + '/' );
281281
282282 if ("file" .equals (scheme )) {
283283 // A maven repository can be expressed as a URI with a file scheme
@@ -372,8 +372,8 @@ public MavenMetadata downloadMetadata(GroupArtifactVersion gav, @Nullable Resolv
372372
373373 String scheme = URI .create (repo .getUri ()).getScheme ();
374374 String uri = repo .getUri () + (repo .getUri ().endsWith ("/" ) ? "" : "/" ) +
375- requireNonNull (gav .getGroupId ()).replace ('.' , '/' ) + '/' +
376- gav .getArtifactId () + '/' ;
375+ requireNonNull (gav .getGroupId ()).replace ('.' , '/' ) + '/' +
376+ gav .getArtifactId () + '/' ;
377377
378378 try {
379379 MavenMetadata .Versioning versioning ;
@@ -513,7 +513,7 @@ public Pom download(GroupArtifactVersion gav,
513513 // The requested gav might itself have an unresolved placeholder in the version, so also check raw values
514514 for (Pom projectPom : projectPoms .values ()) {
515515 if (!projectPom .getGroupId ().equals (gav .getGroupId ()) ||
516- !projectPom .getArtifactId ().equals (gav .getArtifactId ())) {
516+ !projectPom .getArtifactId ().equals (gav .getArtifactId ())) {
517517 continue ;
518518 }
519519
@@ -589,10 +589,10 @@ public Pom download(GroupArtifactVersion gav,
589589
590590 if (result == null ) {
591591 URI uri = URI .create (repo .getUri () + (repo .getUri ().endsWith ("/" ) ? "" : "/" ) +
592- requireNonNull (gav .getGroupId ()).replace ('.' , '/' ) + '/' +
593- gav .getArtifactId () + '/' +
594- gav .getVersion () + '/' +
595- gav .getArtifactId () + '-' + versionMaybeDatedSnapshot + ".pom" );
592+ requireNonNull (gav .getGroupId ()).replace ('.' , '/' ) + '/' +
593+ gav .getArtifactId () + '/' +
594+ gav .getVersion () + '/' +
595+ gav .getArtifactId () + '-' + versionMaybeDatedSnapshot + ".pom" );
596596 uris .add (uri .toString ());
597597 if ("file" .equals (uri .getScheme ())) {
598598 Path inputPath = Paths .get (gav .getGroupId (), gav .getArtifactId (), gav .getVersion ());
@@ -620,9 +620,19 @@ public Pom download(GroupArtifactVersion gav,
620620 RawPom rawPom = RawPom .parse (fis , Objects .equals (versionMaybeDatedSnapshot , gav .getVersion ()) ? null : versionMaybeDatedSnapshot );
621621 Pom pom = rawPom .toPom (inputPath , repo ).withGav (resolvedGav );
622622
623- if (pom .getPackaging () == null || pom . hasJarPackaging ()) {
623+ if (pom .hasJarPackaging ()) {
624624 if (!jarFileExists || jarFile .length () == 0 ) {
625- // The jar has not been downloaded, making this dependency unusable.
625+ // Explicit jar packaging but the JAR is unusable: skip so the next repo can be tried.
626+ continue ;
627+ }
628+ } else if (pom .getPackaging () == null ) {
629+ if (!jarFileExists && !pom .getDependencyManagement ().isEmpty ()) {
630+ // BOM whose <packaging>pom</packaging> was lost in transit (e.g. proxy stripped it).
631+ // Gating on dependencyManagement avoids misidentifying jar artifacts that rely on
632+ // Maven's jar default and happen to have a missing local JAR.
633+ pom = pom .withPackaging ("pom" );
634+ } else if (!jarFileExists || jarFile .length () == 0 ) {
635+ // No BOM signal and the JAR is missing or empty: fall through to the next repo
626636 continue ;
627637 }
628638 }
@@ -778,9 +788,9 @@ private GroupArtifactVersion handleSnapshotTimestampVersion(GroupArtifactVersion
778788 if (gav .getVersion () != null && gav .getVersion ().endsWith ("-SNAPSHOT" )) {
779789 for (ResolvedGroupArtifactVersion pinnedSnapshotVersion : new MavenExecutionContextView (ctx ).getPinnedSnapshotVersions ()) {
780790 if (pinnedSnapshotVersion .getDatedSnapshotVersion () != null &&
781- pinnedSnapshotVersion .getGroupId ().equals (gav .getGroupId ()) &&
782- pinnedSnapshotVersion .getArtifactId ().equals (gav .getArtifactId ()) &&
783- pinnedSnapshotVersion .getVersion ().equals (gav .getVersion ())) {
791+ pinnedSnapshotVersion .getGroupId ().equals (gav .getGroupId ()) &&
792+ pinnedSnapshotVersion .getArtifactId ().equals (gav .getArtifactId ()) &&
793+ pinnedSnapshotVersion .getVersion ().equals (gav .getVersion ())) {
784794 return pinnedSnapshotVersion .getDatedSnapshotVersion ();
785795 }
786796 }
@@ -887,8 +897,8 @@ Iterable<MavenRepository> distinctNormalizedRepositories(
887897 MavenRepository normalized = normalizeRepository (repo , ctx , containingPom );
888898
889899 if (normalized != null &&
890- (acceptsVersion == null || repositoryAcceptsVersion (normalized , acceptsVersion , containingPom )) &&
891- seen .put (normalized .getId (), normalized ) == null ) {
900+ (acceptsVersion == null || repositoryAcceptsVersion (normalized , acceptsVersion , containingPom )) &&
901+ seen .put (normalized .getId (), normalized ) == null ) {
892902 return normalized ;
893903 }
894904 }
@@ -1074,7 +1084,7 @@ private boolean jarExistsForPomUri(MavenRepository repo, String pomUrl) {
10741084 } catch (FailsafeException failsafeException ) {
10751085 Throwable cause = failsafeException .getCause ();
10761086 if (cause instanceof HttpSenderResponseException && hasCredentials (repo ) &&
1077- ((HttpSenderResponseException ) cause ).isClientSideException ()) {
1087+ ((HttpSenderResponseException ) cause ).isClientSideException ()) {
10781088 return Failsafe .with (retryPolicy ).get (() -> {
10791089 HttpSender .Request unauthenticated = httpSender .head (jarUrl ).build ();
10801090 try (HttpSender .Response response = httpSender .send (unauthenticated )) {
0 commit comments