buildscript {
  project.ext {
    if(has('privateRepoDir')) {
      privateRepoDir = privateRepoDir instanceof File ? privateRepoDir.path : privateRepoDir.toString()
      if(!new File(privateRepoDir).isAbsolute())
        privateRepoDir = new File(projectDir, privateRepoDir).canonicalPath
    } else
      privateRepoDir = new File(project.projectDir, '../build/privateRepo').canonicalPath
  }

  def parentGradleProps = new Properties()
  new File(project.projectDir, '../gradle.properties').withInputStream {
    parentGradleProps.load(it)
  }
  ext.parentGradleProps = parentGradleProps.asImmutable()

  ext.parentGradleProps.each { key, value ->
    if(key != 'group' && key != 'version' || key != 'rootProjectName')
      project.ext[key] = value
  }

  repositories {
    maven {
      url "file:$privateRepoDir"
    }
    jcenter()
  }

  dependencies {
    classpath "org.akhikhl.gretty:gretty:${parentGradleProps.version}"
    classpath "org.akhikhl.gretty.internal.integrationTests:gretty-integrationTest:${parentGradleProps.version}"
  }
}

allprojects {
  version = rootProject.ext.parentGradleProps.version
}
