buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'commons-math:commons-math:1.1'
    }
}

configurations {
   spi
}

dependencies {
    compile project(':shared')
    compile module("commons-lang:commons-lang:2.4") {
        dependency("commons-io:commons-io:1.2")
    }
}

// Just a smoke test that using this option does not lead to any exception
compileJava.options.compilerArgs = ['-Xlint:unchecked']

task spiJar(type: Jar) {
    appendix = 'spi'
    from sourceSets.main.output
    include 'org/gradle/api/'
}

artifacts {
  spi spiJar
}

task dist(type: Zip) {
    dependsOn spiJar
    from 'src/dist'
    into('libs') {
        from spiJar.archivePath
        from configurations.runtime
    }
}

artifacts {
   archives dist
}

// We want to test if commons-math was properly added to the build script classpath
org.apache.commons.math.fraction.Fraction lhs = new org.apache.commons.math.fraction.Fraction(1, 3);
org.gradle.buildsrc.BuildSrcClass bsc = new org.gradle.buildsrc.BuildSrcClass()

task checkProjectDependency(dependsOn: project(':shared').jar) << {
    File cachedSharedJarDir = new File(gradle.gradleUserHomeDir, "cache/multiproject/shared/jars")
    copy {
        from project(':shared').jar.archivePath
        into cachedSharedJarDir
    }
    File sharedJar = configurations.compile.files.find { File file -> file.name.startsWith('shared')}
    assert sharedJar.absolutePath == project(':shared').jar.archivePath.absolutePath
}
