Applying plugin in initscript fails


(Joe Harte) #1

I’m perplexed about how init scripts work. Below is my init script where I try to apply a plugin. With the apply plugin ... line commented out everything works fine. In addition, if I add initscript.repositories.each { println "Name: " + + "; url: " + it.url } outside the initscript block the correct values for the repository are printed. But with the apply plugin ... line I get the following error:

Could not find property 'repoUrl' on org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository_Decorated@4d0fbb93.

My init script:

initscript {

    Properties props = new Properties()
    props.load(new File(gradle.gradleUserHomeDir, '').newDataInputStream())

    def repoUrl = props.REPO_URL ?: System.env.REPO_URL
    repositories {
        maven {
            url repoUrl

    dependencies {
        classpath group: '', name: 'gradle-init-plugin', version: '+'

apply plugin:

Note that I am using Gradle 2.13 currently.