Skip to content

Commit

Permalink
Merge pull request #23584 from aloubyansky/support-maven-3.6
Browse files Browse the repository at this point in the history
Support for Maven 3.6.2
  • Loading branch information
aloubyansky authored Feb 10, 2022
2 parents 849f171 + 0a77b2e commit 1629e7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<!--
Supported Maven versions, interpreted as a version range
-->
<supported-maven-versions>[3.8.1,)</supported-maven-versions>
<supported-maven-versions>[3.6.2,)</supported-maven-versions>

<!-- These 2 properties are used by CreateProjectMojo to add the Maven Wrapper -->
<proposed-maven-version>3.8.4</proposed-maven-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,17 @@ private File resolveSettingsFile(String settingsArg, String alternatePomDir, Str
private DefaultRepositorySystemSession newRepositorySystemSession() throws BootstrapMavenException {
final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
final Settings settings = getEffectiveSettings();

final List<Mirror> mirrors = settings.getMirrors();
if (mirrors != null && !mirrors.isEmpty()) {
final boolean isBlockedMethodAvailable = mirrorIsBlockedMethodAvailable();
final DefaultMirrorSelector ms = new DefaultMirrorSelector();
for (Mirror m : mirrors) {
ms.add(m.getId(), m.getUrl(), m.getLayout(), false, m.isBlocked(), m.getMirrorOf(), m.getMirrorOfLayouts());
if (isBlockedMethodAvailable) {
ms.add(m.getId(), m.getUrl(), m.getLayout(), false, m.isBlocked(), m.getMirrorOf(), m.getMirrorOfLayouts());
} else {
// Maven pre-3.8.x
ms.add(m.getId(), m.getUrl(), m.getLayout(), false, m.getMirrorOf(), m.getMirrorOfLayouts());
}
}
session.setMirrorSelector(ms);
}
Expand Down Expand Up @@ -946,4 +951,13 @@ private static boolean isMavenRepoEnvVarOption(String varName, String repoId, St
return varName.length() == BOOTSTRAP_MAVEN_REPO_PREFIX.length() + repoId.length() + option.length()
&& varName.endsWith(option);
}

private static boolean mirrorIsBlockedMethodAvailable() {
try {
Mirror.class.getMethod("isBlocked");
return true;
} catch (Exception e) {
return false;
}
}
}

0 comments on commit 1629e7c

Please sign in to comment.