找不到 ID 为 'org.ajoberstar.grgit' 的插件

Plugin with id 'org.ajoberstar.grgit' not found

我正在尝试编译一个名为 VeinMiner 的开源 minecraft mod。
我用./gradlew build来编译它。
然而它失败了,给我这个原因:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/xxxx/Desktop/VeinMiner/build.gradle' line: 26

* What went wrong:
A problem occurred evaluating root project 'VeinMiner'.
> Plugin with id 'org.ajoberstar.grgit' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 14.778 secs

我已经尝试 git 再次克隆它或 运行 在 sudo 中。
但是,这两个都不行。

这个构建gradle是这样的:
(太长所以我select其中的一部分)

buildscript {
    repositories {
        mavenCentral()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
        maven {
            name = "sonatype"
            url = "https://oss.sonatype.org/content/repositories/snapshots/"
        }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
    }
}

plugins {
    id 'com.matthewprenger.cursegradle' version '1.0.7'
    id 'org.ajoberstar.grgit' version '1.3.2'
}

apply plugin: 'forge'
apply plugin: 'maven'
apply plugin: "org.ajoberstar.grgit"
apply plugin: "com.matthewprenger.cursegradle"

ext.git = grgit.open(file('.'))

ext {
    configFile = file "build.properties"

    revision = git.head().abbreviatedId
    depth = git.log().size()
}

我希望构建成功。有人遇到过这种情况吗?

提到的插件 org.ajoberstar.grgit 被应用了两次。第一次通过新的 plugins 块应用,第二次通过旧的 apply plugin: 方法应用。只需删除行 apply plugin: "org.ajoberstar.grgit",错误就会消失。

要通过旧的 apply plugin: 方法应用插件,需要从 buildscript 块内的任意存储库解析插件包。这与通过正常 repositoriesdependencies 块解决项目依赖关系的方式相同。

新的 plugins 块直接解析来自 Gradle plugin portal 的插件并在同一步骤中应用它们。

我猜应该是plugin的申请方式改成新的了,但是旧的方式并没有被移除。在现有设置中,插件可能已从本地 Gradle 缓存中解析,但在您的新设置中找不到它。