diff --git a/dependencies/build.gradle b/dependencies/build.gradle index 807ef753ecd..6e467ac4448 100644 --- a/dependencies/build.gradle +++ b/dependencies/build.gradle @@ -98,7 +98,7 @@ platformManager.filteredOutEnabledButNotSupported.each { target -> DependencyKind.values().each { kind -> def dir = kind.getDirectory(loader) if (dir != null) { - String path = dependencyProcessor.resolveRelative(dir).canonicalPath + String path = dependencyProcessor.resolve(dir).canonicalPath rootProject.ext.set(kind.getPropertyName(target), path) } } diff --git a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanProperties.kt b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanProperties.kt index 7d78389b393..262cfc94405 100644 --- a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanProperties.kt +++ b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanProperties.kt @@ -58,7 +58,7 @@ abstract class KonanPropertiesLoader(override val target: KonanTarget, = properties.hostTargetList(key, target, host) override fun absolute(value: String?): String = - dependencyProcessor!!.resolveRelative(value!!).absolutePath + dependencyProcessor!!.resolve(value!!).absolutePath private val dependencyProcessor by lazy { baseDir?.let { DependencyProcessor( diff --git a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/util/DependencyProcessor.kt b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/util/DependencyProcessor.kt index c6bbac1aa33..93a566d9809 100644 --- a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/util/DependencyProcessor.kt +++ b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/util/DependencyProcessor.kt @@ -249,7 +249,22 @@ class DependencyProcessor(dependenciesRoot: File, } } - fun resolveRelative(relative: String): File { + /** + * If given [path] is relative, resolves it relative to dependecies directory. + * In case of absolute path just wraps it into a [File]. + * + * Support of both relative and absolute path kinds allows to substitute predefined + * dependencies with system ones. + * + * TODO: It looks like DependencyProcessor have two split responsibilities: + * * Dependency resolving + * * Dependency downloading + * Also it is tightly tied to KonanProperties. + */ + fun resolve(path: String): File = + if (Paths.get(path).isAbsolute) File(path) else resolveRelative(path) + + private fun resolveRelative(relative: String): File { val path = Paths.get(relative) if (path.isAbsolute) error("not a relative path: $relative")