简体   繁体   中英

Unable to use gradle plugin from local Nexus repository

I am trying to use the grgit plugin from within my gradle script. I have a file that is modified by our CI server during build and I want this to be committed to out git repo as part of the build process.

I have a local Nexus repo which has a proxy to maven central. How do i get access to the gradle plugin via my Nexus repo? Currently, I have:

buildscript {
    repositories {
        maven {
            url "http://my-nexus:6666/nexus/content/groups/public/"
        }
    }

    dependencies {
        classpath "org.ajoberstar:grgit:1.7.2"
    }
}

apply plugin: "org.ajoberstar.grgit"

This downloads the dependency from Nexus, but results in > Plugin with id 'org.ajoberstar.grgit' not found. when doing a gradle build .

I have read the documentation regarding custom plugin repositories but prefer the old method rather than the DSL method because I have hundreds of projects and don't want to define the repository in every settings.gradle file since at the moment, pluginRepositories can only be specified in the settings.gradle file.

How can I get the apply plugin method to work?

That's because the version of the Grgit library you use does not have the Gradle plugin included. Only newer versions, that are not in maven central nor jcenter (only in Gradle plugins repository).

You have two ways to fix it

a) Change the library:

buildscript {
    repositories {
        maven {
            url "http://my-nexus:6666/nexus/content/groups/public/"
        }
    }

    dependencies {
        classpath "org.ajoberstar:gradle-git:1.7.2"
    }
}

apply plugin: "org.ajoberstar.grgit"

b) Mirror the gradle-plugins repository in your local Nexus repo from https://plugins.gradle.org/m2/ and version of 2.1.1 grgit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM