Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plugin was not found error during gradle build

Tags:

gradle

When trying to add the org.ajoberstar.grgit plugin into my gradle build, I get the following error:

Plugin [id: 'org.ajoberstar.grgit', version: '2.3.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 
 'org.ajoberstar.grgit:org.ajoberstar.grgit.gradle.plugin:2.3.0')
  Searched in the following repositories:
    Gradle Central Plugin Repository

Here is my code:

import org.ajoberstar.grgit.*

buildscript {
    dependencies {
        classpath 'org.ajoberstar:grgit:2.3.0'
    }
}

plugins {
    id "org.sonarqube" version "2.6"
    id "idea"
    id "org.ajoberstar.grgit" version "2.3.0"
}

// ...

Any idea on how to solve this? Can I somehow manually download the plugin and put it into the cache?

like image 329
Florian Baierl Avatar asked Jan 28 '23 07:01

Florian Baierl


2 Answers

You need to either use:

plugins {
    id "org.ajoberstar.grgit" version "2.3.0"
}

or:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'org.ajoberstar:grgit:2.3.0'
    }
}

apply plugin: 'org.ajoberstar.grgit'
like image 103
Opal Avatar answered Jan 29 '23 20:01

Opal


I am not entirely sure why, but it started working all of a sudden. Here is what I tried:

  • I had "C:/Program Files/..." in my JAVA_OPTS environment variable and replaced that with "C:/Programme/..." (German localization)
  • restarted my PC

After that it magically worked. I am pretty sure it has something to do with the companies proxies and some custom scripts for it (my best guess is that it didn't handle the space character in the JAVA_HOME variable well).

like image 37
Florian Baierl Avatar answered Jan 29 '23 21:01

Florian Baierl