Buildscript section classpath

Hi!

Is there a way to add something to the buildscript (initscript) section?

I have my own gradle plugin published to a corporate nexus. Now I’d like to apply it from the init script. The problem is nexus’s credentials are encrypted and I have to decrypt them to configure a repository. In a standalone project I can use the Credentials Plugin: I add it in the buildscript section, then apply and configure repository. But in my case I need to do it in the initscript section. But seems I even can’t use any thirdparty crypto library.

Hello Alexey,
you mean you want to declare a thirdparty dependency to your init script? yes, you can totally do that.

you can do

initscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "myGroup:myLib:myVersion"
    }
}

to add something to the initscript classpath.

Helo, René

I described the problem not very well, look:

initscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "myGroup:myLib:myVersion"
    }
    myGroup.myLib.utils.Util.doIt() // 2. ...but can't here.
}
myGroup.myLib.utils.Util.doIt() // 1. I can use it here...

Any ideas? Also I mentioned that I can’t use import statements for initscript section. All this is just because the contents of initscript { } is being run separately, as a standalone script, to prepare a dependency model for the rest of a script. And the same goes with buildscript. That’s why you have to specify it’s own repositories.