# Apply script to repositories and dependencies in buildscript block

**URL:** <https://discuss.gradle.org/t/apply-script-to-repositories-and-dependencies-in-buildscript-block/2833>\
**Category:** Old Forum Archive\
**Created:** [April 30, 2014, 7:04am UTC](https://discuss.gradle.org/t/apply-script-to-repositories-and-dependencies-in-buildscript-block/2833 "2014-04-30T07:04:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lzprgmr](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lzprgmr/32/402_2.png) [@lzprgmr](https://discuss.gradle.org/u/lzprgmr)\
**Post date:** [April 30, 2014, 7:04am UTC](https://discuss.gradle.org/t/apply-script-to-repositories-and-dependencies-in-buildscript-block/2833/1 "2014-04-30T07:04:00Z")

</div>

I develop gradle plugins for the rest of the firm to consume, the way how user consume my plugins is by applying a script in their project’s build.gradle:

```gradle
buildscript {
    apply from: 'init.gradle', to: buildscript
}

```

Now I need to separate my init.gradle script into repo.gradle and deps.gradle for some reason, so it actually apply other 2 scripts, as a demo:

```gradle
build.gradle
===========================
buildscript {
    apply from: 'init.gradle', to: buildscript
}
  apply plugin: 'java'
  init.gradle
===========================
apply from: 'repo.gradle', to: repositories
apply from: 'deps.gradle', to: dependencies
  repo.gradle
===========================
repositories {
    ivy {
        ivyPattern "//path/to/repo//[organization]/[module]/ivys/ivy-[revision].xml"
        artifactPattern "//path/to/repo//[organisation]/[module]/[revision]/common/lib/[artifact].[ext]"
    }
}
  deps.gradle
===========================
classpath group: 'ossjava', name: 'freemarker', version: '2.3.19', configuration: 'runtime'

```

The example above actually works, but it is not clear to me how the scope work here, namely: repositories and dependencies: \* apply from: ‘repo.gradle’, to: repositories, I apply repo.gradle to target repositories, but in repo.gradle, I still need to have repositories {} closure, or else it won’t work \* apply from: ‘deps.gradle’, to: dependencies, I apply deps.gradle to target dependencies, but in deps.gradle, I must not have dependencies {} closure, but directly specify classpath for the dependencies.

So what is the rule here? the target or scope here is inconsistent with repositories and dependencies.

The reason I ask is I don’t want to rely on an non-official supported solution that works by coincidence.

Thanks very much.
