diff --git a/plugins/package-managers/conan/src/main/kotlin/Conan.kt b/plugins/package-managers/conan/src/main/kotlin/Conan.kt index 9782a6b81df98..754c4178baee9 100644 --- a/plugins/package-managers/conan/src/main/kotlin/Conan.kt +++ b/plugins/package-managers/conan/src/main/kotlin/Conan.kt @@ -237,20 +237,29 @@ class Conan( return } - // Iterate over configured remotes. - remoteList.stdout.lines().forEach { line -> + val remotes = parseConanRemoteList(remoteList.stdout) + configureUserAuthentication(remotes) + } + + private fun parseConanRemoteList(remoteList: String): List> = + remoteList.lines().mapNotNull { line -> // Extract the remote URL. val trimmedLine = line.trim() - if (trimmedLine.isEmpty() || trimmedLine.startsWith('#')) return@forEach + if (trimmedLine.isEmpty() || trimmedLine.startsWith('#')) return@mapNotNull null val wordIterator = trimmedLine.splitToSequence(' ').iterator() - if (!wordIterator.hasNext()) return@forEach + if (!wordIterator.hasNext()) return@mapNotNull null val remoteName = wordIterator.next() - if (!wordIterator.hasNext()) return@forEach + if (!wordIterator.hasNext()) return@mapNotNull null val remoteUrl = wordIterator.next() + remoteName to remoteUrl + } + + private fun configureUserAuthentication(remotes: List>) = + remotes.forEach { (remoteName, remoteUrl) -> remoteUrl.toUri().onSuccess { uri -> logger.info { "Found remote '$remoteName' pointing to URL $remoteUrl." } @@ -269,7 +278,6 @@ class Conan( logger.warn { "The remote '$remoteName' points to invalid URL $remoteUrl." } } } - } /** * Return the dependency tree for the given [direct scope dependencies][requires].