无法为参数 Gradle 找到方法 compile() [英] Could not find method compile() for arguments Gradle

查看:25
本文介绍了无法为参数 Gradle 找到方法 compile()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在寻找这个解决方案的时间太长了,我不确定是我错过了它还是只是打错了一些东西,但我的 Gradle 脚本无法编译.我正在迁移到 Gradle,并且对它非常陌生.我非常习惯使用 Maven 进行依赖管理,但 Gradle 现在似乎是我最好的选择.运行这段代码:

Looked around for this solution for much too long now, and I'm not sure if I missed it or just misstyped something, but my Gradle script will not compile. I am migrating to Gradle, and am very new with it. I am very used to using Maven for dependency management, but Gradle seems best me for now. From running this snippet of code:

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 插件.

NOTE: I do have the java, maven, nexus, shadow, and rebel plugins applied.

当我运行 Gradle 任务时,遇到此错误:

When I run my Gradle task, I encounter this error:

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

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

If I remove the MattLib dependency from my project and reinsert it as

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

脚本已完成,但我有依赖性问题.我在这里阅读:

The script completes, but I have dependency issues. I read up here:

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

(来自 Gradle 手册的第 50 章)

(From Chapter 50 From the Gradle Manual)

我所拥有的应该有效,但我很困惑为什么它不起作用.

that what I have SHOULD work, but I am confused why it doesn't.

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

推荐答案

应该是 exclude module: 'net.milkbowl:vault:1.2.27'(add module:code>) 如 DependencyHandler 文档中所述 从这里链接 因为使用了 ModuleDependency.exclude(java.util.Map) 方法.

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.

这篇关于无法为参数 Gradle 找到方法 compile()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆