Scripting: avoid CME in maven resolving in IDE scenarios

combination of laziness in AetherResolveSession and possibly
async-modifiable repos collection in MavenDependenciesResolver
may lead to the CME.
#KT-54733 fixed
This commit is contained in:
Ilya Chernikov
2023-01-05 11:27:26 +01:00
parent 6c035bb5f4
commit ea255135a4
@@ -43,7 +43,7 @@ class MavenDependenciesResolver : ExternalDependenciesResolver {
val repos: ArrayList<RemoteRepository> = arrayListOf()
private fun remoteRepositories() = if (repos.isEmpty()) arrayListOf(mavenCentral) else repos
private fun remoteRepositories() = if (repos.isEmpty()) arrayListOf(mavenCentral) else repos.toList() // copy to avoid sharing problems
private fun String.toMavenArtifact(): DefaultArtifact? =
if (this.isNotBlank() && this.count { it == ':' } >= 2) DefaultArtifact(this)