我必须创建一个本地 Maven 存储库,因此 Android 项目将能够仅从这个本地存储库构建。
从日志看来插件实际上已经解决了。 但由于某种原因,我不断收到以下错误。
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.jetbrains.kotlin.android', version: '1.9.22'] was not found in any of the following sources:
有人可以帮我吗?
简短日志:
Attempting to resolve component for org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.9.22 using repositories [maven]
Loading file:/C:/Users/test/Documents/Github/Work/test/local-maven-repo/org/jetbrains/kotlin/android/org.jetbrains.kotlin.android.gradle.plugin/1.9.22/org.jetbrains.kotlin.android.gradle.plugin-1.9.22.pom
Attempting to resolve component for org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.22 using repositories [maven]
Loading file:/C:/Users/test/Documents/Github/Work/test/local-maven-repo/org/jetbrains/kotlin/kotlin-gradle-plugins-bom/1.9.22/kotlin-gradle-plugins-bom-1.9.22.pom
Metadata file found for module 'org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.22' in repository 'maven'.
Loading file:/C:/Users/test/Documents/Github/Work/test/local-maven-repo/org/jetbrains/kotlin/kotlin-gradle-plugins-bom/1.9.22/kotlin-gradle-plugins-bom-1.9.22.module
Recording module descriptor in cache: org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.22 [changing = false]
Using org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.22 from Maven repository 'maven'
Loading file:/C:/Users/test/Documents/Github/Work/test/local-maven-repo/org/jetbrains/kotlin/kotlin-gradle-plugins-bom/1.9.22/kotlin-gradle-plugins-bom-1.9.22.pom
Downloaded artifact 'kotlin-gradle-plugins-bom-1.9.22.pom (org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.22)' from resolver: maven
Flushing resolved configuration data in Binary store in C:\Users\test\.gradle\.tmp\gradle17832654540797845168.bin. Wrote root 2.
Build operation 'Resolve dependencies of detachedConfiguration1' completed
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.jetbrains.kotlin.android', version: '1.9.22'] was not found in any of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
Plugin Repositories (could not resolve plugin artifact 'org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.9.22')
Searched in the following repositories: maven // this is my local repo.
完整日志如下:https://gist.github.com/romanlapa/d164589bb5f19e0416500b2f623eda7f
我做了什么。
mvn dependency:resolve
。例如
org.jetbrains.kotlin.android.gradle.plugin-1.9.22
默认情况下有不同的名称:kotlin-gradle-plugin-1.9.22
.
我的配置。
settings.build.gradle:
pluginManagement {
repositories {
maven(uri("$rootDir/local-maven-repo"))
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven(uri("$rootDir/local-maven-repo"))
}
}
rootProject.name = "MyApplication4"
include(":app")
build.gradle.kts:
plugins {
id("com.android.application") version "8.0.0"
kotlin("android") version "1.9.22"
//id("org.jetbrains.kotlin.android") version "1.9.22"
id("maven-publish")
}
...
Gradle 插件发布在它们自己的特殊 Maven 工件中,以便 Gradle 可以单独使用它们的 id 从存储库解析它们。
这个神器有坐标:
org.jetbrains.kotlin.android
).gradle.plugin
附加的插件id(例如org.jetbrains.kotlin.android.gradle.plugin
)您可以以这种方式使用插件 POM 手动安排本地存储库,也可以使用此信息编写一个小 Gradle 项目,以使用 Maven Publish 插件重新发布该插件。 (我建议后者。如何做到这一点的完整细节可能超出了这个问题的范围。)
您看起来已经正确声明了存储库,因此按照这种方式安排,Gradle 应该能够从您的存储库解析插件。