【问题标题】:Gradle Configuration of pluginRepositorypluginRepository 的 Gradle 配置
【发布时间】:2016-11-08 08:11:06
【问题描述】:

我正在尝试获得一个简单的 Gradle 项目(由 eclipse 自动创建的项目),由 Sonar 进行静态代码分析,以在我们的持续集成上运行。我们的 CI 服务器位于代理后面,我必须通过内部 Nexus 服务器访问 Gradle 插件存储库。

userguide 中所述,我已将以下内容添加到我的 settings.gradle

pluginRepositories {
  maven {
    url 'http://link.to.my.nexus'
  }
  gradlePluginPortal()
}

rootProject.name = 'GradleTestProject'

我的 build.gradle 看起来像这样:

plugins {
  id "org.sonarqube" version "2.0.1"
}

apply plugin: 'java'

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.21'

    testCompile 'junit:junit:4.12'
}

当我在 Jenkins 上运行它时,我收到以下错误消息:

FAILURE: Build failed with an exception.

* Where:
Settings file '/opt/hudson/jobs/GradleTestProject/workspace/settings.gradle' line: 1

* What went wrong:
A problem occurred evaluating settings 'workspace'.
> Could not find method pluginRepositories() for arguments [settings_20tc2o9xuj82hi1fvpe4wvcvt$_run_closure1@52b56c40] on settings 'workspace'.

我查看了网络上的其他示例。他们都按照我描述的方式进行操作。

顺便说一句:我使用的是 Gradle 2.12

【问题讨论】:

  • 好像版本太低了,试试2.14吧。

标签: plugins jenkins gradle sonarqube sonarqube-scan


【解决方案1】:

我使用的是 4.0.1 版本。

我遇到了同样的错误,发现你的问题没有答案,最后我在 settings.gradle 中找到并尝试了这个,现在它可以工作了。

pluginManagement {
    repositories {
        gradlePluginPortal()

    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-24
    • 2020-02-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多