# buildscript.configurations.classpath not available in apply from scripts

**URL:** <https://discuss.gradle.org/t/buildscript-configurations-classpath-not-available-in-apply-from-scripts/1391>\
**Category:** Old Forum Archive\
**Created:** [October 5, 2012, 5:52pm UTC](https://discuss.gradle.org/t/buildscript-configurations-classpath-not-available-in-apply-from-scripts/1391 "2012-10-05T17:52:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![quidryan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/quidryan/32/73_2.png) [@quidryan](https://discuss.gradle.org/u/quidryan)\
**Post date:** [October 5, 2012, 5:52pm UTC](https://discuss.gradle.org/t/buildscript-configurations-classpath-not-available-in-apply-from-scripts/1391/1 "2012-10-05T17:52:00Z")

</div>

I’m trying to use a class available in the buildscript.configurations.classpath. This works fine in the main build.gradle, but when I move the code to a _apply from: ‘file.gradle’_ it is no longer available.

This works:

```gradle
buildscript {
  repositories { mavenCentral() }
  dependencies { classpath 'org.ajoberstar:gradle-git:0.2.2' }
}
import org.ajoberstar.gradle.git.tasks.*
task add(type: GitAdd) {
}

```

This does not work:

```gradle
buildscript {
  repositories { mavenCentral() }
  dependencies { classpath 'org.ajoberstar:gradle-git:0.2.2' }
}
  apply from: 'git.gradle'

```

git.gradle:

```gradle
import org.ajoberstar.gradle.git.tasks.*
task add(type: GitAdd) {
}

```

Reading the Gradle User Guide makes very few references to apply from. If I print out buildscript.configurations.classpath in the git.gradle file, it shows an empty list of dependencies, while it’s looks perfectly find in the build.gradle.

---

<div class="post-metadata">

**Author:** ![Spencer\_Allain](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Spencer\_Allain](https://discuss.gradle.org/u/Spencer_Allain)\
**Post date:** [October 6, 2012, 11:49am UTC](https://discuss.gradle.org/t/buildscript-configurations-classpath-not-available-in-apply-from-scripts/1391/2 "2012-10-06T11:49:00Z")

</div>

Applied scripts do not inherit anything from their applying script(s) to my knowledge, so the buildscript section of the build.gradle file is not seen by git.gradle.

If you copy the buildscript section from build.gradle into git.gradle, it should work fine. You probably will not even need that buildscript section to remain in build.gradle at all, depending upon whether there are other things you wish to pull directly from your gradle-git classes.

Maybe in the future, there will be some way to apply and have the ability to pre-inject buildscript object configuration details into a script being applied. The dependencies are usually unique, but often the repositories need to be set differently to work in all desired target environments.

-Spencer

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [October 23, 2012, 2:59pm UTC](https://discuss.gradle.org/t/buildscript-configurations-classpath-not-available-in-apply-from-scripts/1391/3 "2012-10-23T14:59:00Z")

</div>

Spencer is right, script plugins are classloader isolated. Your script plugin has its own ‘buildscript’ block.

If you need to “export” types from the script plugin to the applier, you can add them as variables:

```gradle
// git.gradle
buildscript { … }
ext.GitAdd = GitAdd
  // build.gradle
apply from: "git.gradle"
task add(type: GitAdd) {}

```

It’s hackish, but works. We are aware that there’s some awkwardness here and will address it at some point.
