diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenWrapperSupport.kt b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenWrapperSupport.kt index 2ca53cbb6f5b3..e87d261fa7f8e 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenWrapperSupport.kt +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenWrapperSupport.kt @@ -66,6 +66,13 @@ internal class MavenWrapperSupport { indicator?.apply { text = SyncBundle.message("maven.sync.wrapper.downloading.from", urlString) } try { HttpRequests.request(urlString) + .tuner{ + val username = System.getenv("MVNW_USERNAME") + val password = System.getenv("MVNW_PASSWORD") + if (!username.isNullOrBlank() && !password.isNullOrBlank()) { + it.setRequestProperty("Authorization", "Basic " + Base64.getEncoder().encodeToString("$username:$password".toByteArray())) + } + } .forceHttps(false) .connectTimeout(30_000) .readTimeout(30_000) @@ -185,7 +192,14 @@ internal class MavenWrapperSupport { val stream = ByteArrayInputStream(wrapperProperties.contentsToByteArray(true)) properties.load(stream) - return properties.getProperty(DISTRIBUTION_URL_PROPERTY) + val configuredProperty = properties.getProperty(DISTRIBUTION_URL_PROPERTY) + val urlBase = System.getenv("MVNW_REPOURL") + val configuredUrlBaseEnd = configuredProperty?.indexOf("/org/apache/maven") ?: -1 + if (!urlBase.isNullOrBlank() && configuredUrlBaseEnd >= 0) { + return (if (urlBase.endsWith('/')) urlBase.substring(0, urlBase.length - 1) else urlBase) + configuredProperty.substring(configuredUrlBaseEnd) + } + + return configuredProperty } catch (e: IOException) { MavenLog.LOG.warn("exception reading wrapper url", e) @@ -227,4 +241,4 @@ internal class MavenWrapperSupport { fun getWrapperProperties(baseDir: VirtualFile?) = baseDir?.findChild(".mvn")?.findChild("wrapper")?.findChild("maven-wrapper.properties") } -} \ No newline at end of file +}