2016-07-06 65 views
5

我想通過由Sonar進行的靜態代碼分析來獲得簡單的Gradle項目(由eclipse自動創建的項目),以便在我們的持續集成上運行。我們的CI服務器位於代理之後,我必須通過內部Nexus服務器訪問Gradle插件庫。插件庫的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' 
} 

,當我在詹金斯運行此,我得到以下錯誤消息:

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 [[email protected]] on settings 'workspace'. 

我已經看過網絡中的其他示例。他們都像我描述的一樣。

順便說一句:我正在使用Gradle 2.12

+1

看來版本太低,試着用'2.14'。 – Opal

回答

0

我在版本4.0.1。

我有同樣的錯誤,發現你的問題沒有答案,最後我發現並試圖在settings.gradle,現在它的工作原理。

pluginManagement { 
    repositories { 
     gradlePluginPortal() 

    } 
}