在 kotlin 多平台移动 gradle 构建中,什么是“ivy”存储库?它来自哪里以及如何修复/删除它?

Mar*_*tek 8 android gradle ios kotlin kotlin-multiplatform

在使用 Kotlin 多平台移动项目时,我在配置项目时收到此错误。特别是通过 Xcode 内的 iOS 默认脚本构建它时。

这是错误

> Configure project :HomeShared
Kotlin Multiplatform Projects are an Alpha feature. See: https://kotlinlang.org/docs/reference/evolution/components-stability.html. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.
The property 'kotlin.mpp.enableGranularSourceSetsMetadata=true' has no effect in this and future Kotlin versions, as Hierarchical Structures support is now enabled by default. It is safe to remove the property.
The property 'kotlin.native.enableDependencyPropagation=false' has no effect in this and future Kotlin versions, as Kotlin/Native dependency commonization is now enabled by default. It is safe to remove the property.
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/vagrant/git/HomeShared/HomeShared/build.gradle.kts' line: 17
* What went wrong:
Build was configured to prefer settings repositories over project repositories but repository 'ivy' was added by build file '/Users/vagrant/git/HomeShared/HomeShared/build.gradle.kts'
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Run Code Online (Sandbox Code Playgroud)

这是HomeShared/build.gradle.kts错误中提到的:

buildscript {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
        classpath("com.android.tools.build:gradle:7.2.2")
        classpath("org.jetbrains.kotlin:kotlin-serialization:1.7.10")
    }
}

plugins {
    id("com.android.application").version("7.3.0").apply(false)
    id("com.android.library").version("7.3.0").apply(false)
    kotlin("android").version("1.7.10").apply(false)
    kotlin("multiplatform").version("1.7.10").apply(false)
}

tasks.register("clean", Delete::class) {
    delete(rootProject.buildDir)
} 
Run Code Online (Sandbox Code Playgroud)

我现在的问题是

  1. 为什么它可以在某些机器上构建,而不能在其他机器上构建?
  2. 什么是“ivy”存储库,如何删除它并按指定使用 Maven?
  3. “常春藤”这个参考来自哪里?(我从来没有在项目中明确提到过)

ahm*_*dre 5

在 Kotlin 存储库中,Ivy 正在使用,从Kotlin 存储库的搜索中可以看出。话虽如此,此错误是由于在标志中settings.gradlesettings.gradle.kts使用FAIL_ON_PROJECT_REPOS标志声明存储库而发生的,即:

repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
Run Code Online (Sandbox Code Playgroud)

您可以将其切换为 或RepositoriesMode.PREFER_PROJECTRepositoriesMode.PREFER_SETTINGS或完全删除该行,与 相同RepositoriesMode.PREFER_PROJECT)来解决此问题。您可以在此Kotlin Slack 线程中查看更多详细信息。