我是 gradle 新手(从 Maven 离开)。现在我有一个问题。我有一个 gradle 构建,我想在其中使用com.bmuschko.nexus
插入。但我的项目依赖于另一个项目,我也想在其中使用com.bmuschko.nexus
plugin.
所以当我构建时我得到一个异常:
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.
我该如何解决这个问题?
设置.gradle
include ':config'
project(':config').projectDir = new File(settingsDir, '../zConfig')
构建.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')
}
编辑:要重现只需克隆存储库https://github.com/KIC/stackoverflow/tree/master/gradleproblem https://github.com/KIC/stackoverflow/tree/master/gradleproblem并尝试gradle tasks
在 bar 目录中
EDIT2:似乎我可以通过省略插件并遵循此答案来解决 Nexus 上传问题https://stackoverflow.com/a/16766946/1298461 https://stackoverflow.com/a/16766946/1298461
但由于我还有一个 antlr 项目和第二个 antlr 项目扩展了第一个项目的语法,所以我在使用另一个插件时遇到了同样的问题。我想当我使用父 build.gradle 和子项目{}时我可以解决这个问题。但这正是我离开maven并转向gradle的原因。我的子模块可以而且也应该独立存在于不同的版本中。