# Buildscript section classpath

**URL:** https://discuss.gradle.org/t/buildscript-section-classpath/31333
**Category:** Help/Discuss
**Created:** [April 8, 2019, 4:47pm UTC](https://discuss.gradle.org/t/buildscript-section-classpath/31333 "2019-04-08T16:47:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![apomelov](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/apomelov/32/7626_2.png) [@apomelov](https://discuss.gradle.org/u/apomelov)
#### Post date: [April 8, 2019, 4:47pm UTC](https://discuss.gradle.org/t/buildscript-section-classpath/31333/1 "2019-04-08T16:47:41Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Rene](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/rene/32/8082_2.png) [@Rene](https://discuss.gradle.org/u/Rene)
#### Post date: [April 8, 2019, 10:21pm UTC](https://discuss.gradle.org/t/buildscript-section-classpath/31333/2 "2019-04-08T22:21:26Z")

</div>

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

you can do

```gradle
initscript {
    repositories {
        mavenCentral()
    }

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

```

to add something to the initscript classpath.

---

<div class="post-metadata">

### Author: ![apomelov](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/apomelov/32/7626_2.png) [@apomelov](https://discuss.gradle.org/u/apomelov)
#### Post date: [April 9, 2019, 5:57am UTC](https://discuss.gradle.org/t/buildscript-section-classpath/31333/3 "2019-04-09T05:57:43Z")

</div>

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.
