【发布时间】:2015-04-28 18:07:47
【问题描述】:
我是 gradle 的新手(从 maven 离开)。现在我有一个问题。我有一个 gradle 构建,我想在其中使用 com.bmuschko.nexus 插件。但我的项目依赖于另一个我也想使用com.bmuschko.nexus 插件的项目。
所以当我构建时我得到一个异常:
Plugin 'com.bmuschko.nexus' is already on the script classpath. Plugins on the script classpath cannot be applied in the plugins {} block. Add "apply plugin: 'com.bmuschko.nexus'" to the body of the script to use the plugin.
但是当我这样做时 -> 将 apply plugin: 'com.bmuschko.nexus' 添加到脚本的主体以使用插件我得到另一个异常:
> Failed to apply plugin [id 'com.bmuschko.nexus']
> Plugin with id 'com.bmuschko.nexus' not found.
我该如何解决这个问题?
settings.gradle
include ':config'
project(':config').projectDir = new File(settingsDir, '../zConfig')
build.gradle
plugins {
// id "com.bmuschko.nexus" version "2.3" // already in classpath
id "me.champeau.gradle.antlr4" version "0.1"
}
apply plugin: 'java'
apply plugin: 'maven'
//apply plugin: 'com.bmuschko.nexus'
dependencies {
compile project(':config')
}
编辑:复制只需克隆 repo https://github.com/KIC/stackoverflow/tree/master/gradleproblem 并在 bar 目录中尝试 gradle tasks
EDIT2:似乎我可以通过省略插件并按照这个答案https://stackoverflow.com/a/16766946/1298461来解决nexus上传问题@
但是由于我还有一个 antlr 项目和第二个 antlr 项目扩展了第一个项目的语法,所以我在使用另一个插件时也遇到了同样的问题。我想当我使用父 build.gradle 和 subprojects{} 时我可以解决这个问题。但这正是我离开 maven 并转向 gradle 的原因。我的子模块可以也应该独立于不同的版本。
【问题讨论】:
-
看来,如果插件已经应用,你可以直接使用它。无需重新应用它,只需通过配置并运行适当的任务。
gradle tasks运行时是否列出了来自上述插件的任务? -
很遗憾,没有,由于该项目处于依赖关系中,因此设置将无法正常工作,因此 gradle 失败
Could not find method nexus() for arguments -
该项目是否在线托管?
-
@Opal 不,它不在线