找不到参数 Gradle 的方法 compile()

新手上路,请多包涵

现在环顾这个解决方案太久了,我不确定我是错过了它还是只是输入了错误的东西,但是我的 Gradle 脚本无法编译。我正在迁移到 Gradle,并且对它非常陌生。我非常习惯使用 Maven 进行依赖管理,但 Gradle 似乎是我现在最好的选择。通过运行这段代码:

 dependencies {
  compile group: 'org.bukkit', name: 'bukkit', version: '1.7.9-R0.1-SNAPSHOT'
  compile('io.ibj:MattLib:1.1-SNAPSHOT') {
    exclude group: 'de.bananaco'
    exclude 'net.milkbowl:vault:1.2.27'
  }
  compile group: 'net.citizensnpcs', name: 'citizens', version: '2.0.12'
  compile group: 'com.sk89q', name: 'worldedit', version: '5.6.1'
  compile group: 'com.sk89q', name: 'worldguard', version: '5.9'
  compile group: 'net.milkbowl', name: 'vault', version: '1.2.12'
  compile fileTree(dir: 'libs', includes: ['*.jar'])
}

注意: 我确实应用了 java、maven、nexus、shadow 和 rebel 插件。

当我运行我的 Gradle 任务时,我遇到了这个错误:

 Could not find method compile() for arguments [[io.ibj:MattLib:1.1-SNAPSHOT], build_1b5iofu9r9krp7o8mme0dqo9l$_run_closure2_closure8@66fb45e5] on root project 'project'

如果我从我的项目中删除 MattLib 依赖项并将其重新插入为

compile 'io.ibj:MattLib:1.1-SNAPSHOT'

脚本完成,但我有依赖问题。我在这里读到:

 dependencies {
  compile("org.gradle.test.excludes:api:1.0") {
    exclude module: 'shared'
  }
}

(来自 Gradle 手册的 第 50 章)

那我应该工作,但我很困惑为什么它不工作。

gradle --version 输出:

 Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy:          2.2.0
JVM:          1.8.0_05 (Oracle Corporation 25.5-b02)
OS:           Windows 7 6.1 amd64

原文由 Ichbinjoe 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 804
2 个回答

It should be exclude module: 'net.milkbowl:vault:1.2.27' (add module: ) as explained in documentation for DependencyHandler linked from here because ModuleDependency.exclude(java.util.Map) method is used.

原文由 Radim 发布,翻译遵循 CC BY-SA 4.0 许可协议

Note that the compile , runtime , testCompile , and testRuntime configurations introduced by the Java plugin have been deprecated since Gradle 4.10 ( Aug 27 , 2018 年),并最终在 Gradle 7.02021 年 4 月 9 日)中删除。

The aforementioned configurations should be replaced by implementation , runtimeOnly , testImplementation , and testRuntimeOnly , respectively.

原文由 ashelkov 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题