# Accessing ext properties from within "buildscript" closure

**URL:** <https://discuss.gradle.org/t/accessing-ext-properties-from-within-buildscript-closure/3603>\
**Category:** Old Forum Archive\
**Created:** [June 25, 2013, 4:14pm UTC](https://discuss.gradle.org/t/accessing-ext-properties-from-within-buildscript-closure/3603 "2013-06-25T16:14:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gunnar\_Morling](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gunnar_morling/32/735_2.png) [@Gunnar\_Morling](https://discuss.gradle.org/u/Gunnar_Morling)\
**Post date:** [June 25, 2013, 4:14pm UTC](https://discuss.gradle.org/t/accessing-ext-properties-from-within-buildscript-closure/3603/1 "2013-06-25T16:14:00Z")

</div>

Hi,

I’m trying to centralize the repository URLs of my build script as external variables:

```gradle
ext {
    jbossPublicUrl = 'http://repository.jboss.org/nexus/content/groups/public/'
}

```

Everything works as expected when referring to this property from within the “allprojects” closure:

```gradle
allprojects {
    repositories {
        mavenRepo name: 'jboss-public', url: rootProject.jbossPublicUrl
    }
}

```

I don’t know though how to refer to the property from within the “buildscript” closure:

```gradle
buildscript {
    repositories {
        //doesn't work, "rootProject" is not known here
        mavenRepo name: 'jboss-public', url: rootProject.jbossPublicUrl
    }
 }

```

Is there any way to accomplish this task?

Many thanks,

–Gunnar

---

<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:** [July 1, 2013, 10:52am UTC](https://discuss.gradle.org/t/accessing-ext-properties-from-within-buildscript-closure/3603/2 "2013-07-01T10:52:00Z")

</div>

You have to declare the properties inside ‘buildscript {}’ to be able to access them there.

The buildscript {} block is evaluated before _anything_ else in the script (regardless of location in file).
