Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Configuration of pluginRepository

I am trying to get a simple Gradle project (the one that is created by eclipse automatically) with static code analysis made by Sonar to run on our continuous integration. Our CI server is behind a proxy and i have to access the Gradle plugin repository over an internal Nexus server.

As described in the userguide i have added the following to my settings.gradle

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

rootProject.name = 'GradleTestProject'

my build.gradle looks like this:

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'
}

When i run this on Jenkins, i get the following error message:

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'.

I have looked at other examples in the web. They all do it the same way as i described.

BTW: I am using Gradle 2.12

like image 828
cpetry Avatar asked Jul 06 '16 09:07

cpetry


1 Answers

I'm in version 4.0.1.

I had the same error, found your question without answer and finally I found and tried this in settings.gradle and now it works.

pluginManagement {
    repositories {
        gradlePluginPortal()

    }
}
like image 55
Christof Hullaert Avatar answered Oct 18 '22 01:10

Christof Hullaert