【问题标题】:Gradle plugin dependency exists but isn't found during the buildGradle 插件依赖存在但在构建期间未找到
【发布时间】:2018-12-17 23:55:23
【问题描述】:

似乎我所拥有的是正确的,但 Gradle 仍然找不到插件。

我的插件子句看起来像:

plugins {
    id "io.codearte.nexus-staging" version "0.8.0"
}

构建错误如下:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/local/MAGICLEAP/doprea/development/java/JenkinsPipelineUnit-1.1/build.gradle' line: 4

* What went wrong:
Plugin [id: 'io.codearte.nexus-staging', version: '0.8.0'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'io.codearte.nexus-staging:io.codearte.nexus-staging.gradle.plugin:0.8.0')
  Searched in the following repositories:
    Gradle Central Plugin Repository

但是,CR 似乎有它:

https://plugins.gradle.org/plugin/io.codearte.nexus-staging/0.8.0

..那里提供的依赖条款与我已经拥有的相同。

我错过了什么吗?

【问题讨论】:

  • 您是否也尝试过最新的 0.11.0 版本?您是否尝试过包含插件的旧机制?您是否仔细检查了添加插件的新机制是否适用于您的项目设置?请参阅插件页面plugins.gradle.org/plugin/…的“关于新插件机制”部分
  • 实际上,旧语法有效。知道为什么新的没有吗?看起来用法很简单,不会有任何并发​​症。
  • 这取决于您的项目设置。我整理了一个答案并指出了可能的原因。
  • 我认为您遇到的问题与plugin is not in 'org.gradle' namespace 部分有关。但是,我似乎找不到任何有关何时/如何应用对 org.gradle 命名空间的限制的更多信息。我知道发布到 Gradle 门户但使用此命名空间的插件需要在公开可用之前获得批准,但这似乎不是这里的问题......跨度>
  • 你能解决这个问题吗?

标签: java gradle


【解决方案1】:

插件页面说明了包含插件的两种方式 (https://plugins.gradle.org/plugin/io.codearte.nexus-staging#new-plugin-mechanism-info)。一个for plugins DSL for Gradle 2.1 和一个for use in older Gradle versions or where dynamic configuration is required。 Gradle 插件 DSL 版本有一些限制,在任何情况下都不起作用,例如

  1. 只能在构建脚本中使用。
  2. 不能与子项目 {}、所有项目 {} 等结合使用。
  3. plugins {} 块也必须是构建脚本中的顶级语句

如果插件 DSL 版本不适合您,则应使用其他方式包含它。

【讨论】:

  • 是的。我以前能够使用该遗留样式解决问题。
【解决方案2】:

添加

rootProject.buildFileName = 'build.gradle.kts'

在 settings.gradle 文件的第一行应该对你有帮助。

@参考:reference link

【讨论】:

  • 我相信 .kts 适用于 kotlin 项目
猜你喜欢
  • 2020-03-19
  • 1970-01-01
  • 2016-04-09
  • 1970-01-01
  • 1970-01-01
  • 2014-03-08
  • 2021-02-15
  • 1970-01-01
  • 2016-07-11
相关资源
最近更新 更多