Skip to content

Commit 08cef9b

Browse files
oheger-boschsschuberth
authored andcommitted
fix(maven): Do not override repository properties with unset values
When setting up the remote repositories to request a remote artifact, only set the proxy and the authentication if they are actually defined in the current repository session. Otherwise, properties that might have been initialized elsewhere (e.g. by Gradle) can be overridden. While at it, switch from a `map { ... }.toSet()` construct to a `mapTo (mutableSetOf()) { ... }`. Signed-off-by: Oliver Heger <[email protected]>
1 parent 309c5a3 commit 08cef9b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

plugins/package-managers/maven/src/main/kotlin/utils/MavenSupport.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,12 @@ class MavenSupport(private val workspaceReader: WorkspaceReader) : Closeable {
303303
val remoteRepositories = allRepositories.filterNot {
304304
// Some (Linux) file URIs do not start with "file://" but look like "file:/opt/android-sdk-linux".
305305
it.url.startsWith("file:/")
306-
}.map { repository ->
307-
val proxy = repositorySystemSession.proxySelector.getProxy(repository)
308-
val authentication = repositorySystemSession.authenticationSelector.getAuthentication(repository)
309-
RemoteRepository.Builder(repository).setAuthentication(authentication).setProxy(proxy).build()
310-
}.toSet()
306+
}.mapTo(mutableSetOf()) { repository ->
307+
RemoteRepository.Builder(repository).apply {
308+
repositorySystemSession.proxySelector.getProxy(repository)?.also(::setProxy)
309+
repositorySystemSession.authenticationSelector.getAuthentication(repository)?.also(::setAuthentication)
310+
}.build()
311+
}
311312

312313
if (allRepositories.size > remoteRepositories.size) {
313314
logger.debug { "Ignoring local repositories ${allRepositories - remoteRepositories}." }

0 commit comments

Comments
 (0)