buildscript {
    repositories {
        jcenter()
        maven {
            url 'http://repo.jenkins-ci.org/releases/'
        }
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-nexus-plugin:0.7'
        classpath 'com.gradle.publish:plugin-publish-plugin:0.9.10'
    }
}

apply plugin: 'com.gradle.plugin-publish'
apply plugin: 'java-gradle-plugin'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'nexus'

sourceCompatibility = 1.6
targetCompatibility = 1.6

repositories {
    addAll(buildscript.repositories)
}

sourceSets {
    integTest {
        compileClasspath += sourceSets.main.output
    }
}

configurations {
    integTestCompile.extendsFrom testCompile
    integTestRuntime.extendsFrom testRuntime
    jenkins
}

dependencies {
    compile(
        gradleApi(),
        localGroovy(),
        'xmlunit:xmlunit:1.3'
    )

    compile('org.jenkins-ci:version-number:1.1')

    compile('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2') {
        exclude(module: 'groovy')
    }

    compile('org.jenkins-ci.plugins:job-dsl-core:1.67') {
        exclude(module: 'groovy-all')
    }

    compile 'com.google.guava:guava:19.0'

    testCompile('com.netflix.nebula:nebula-test:3.1.0') {
        exclude(module: 'groovy-all')
    }

    testCompile('org.spockframework:spock-core:1.0-groovy-2.4') {
        exclude(module: 'groovy-all')
    }

    integTestCompile gradleTestKit()

    jenkins('org.jenkins-ci.main:jenkins-war:1.+') { transitive = false }
}

if (! project.hasProperty('jenkinsPort')) {
    ext.jenkinsPort = 9999
}

task integTest(type: Test) {
    binResultsDir = file("${buildDir}/integTest-results/binary/integTest")
    reports.html.destination = "${buildDir}/reports/integTest"
    reports.junitXml.destination = "${buildDir}/integTest=results"
    classpath = sourceSets.integTest.runtimeClasspath
    testClassesDir = compileIntegTestJava.destinationDir

    systemProperty "jenkins.port", "${jenkinsPort}"
    shouldRunAfter test
}
check.dependsOn integTest

afterEvaluate {
    javadocJar {
        setDependsOn([groovydoc])
        from groovydoc
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.12'
}

nexus {
    sign = false
}

modifyPom {
    project {
        name 'gradle-jenkins-plugin'
        description 'This is a gradle plugin for programmatically configuring Jenkins jobs.'
        url 'https://github.com/ghale/gradle-jenkins-plugin'
        inceptionYear '2012'

        scm {
            url 'https://github.com/ghale/gradle-jenkins-plugin.git'
            connection 'scm:https://github.com/ghale/gradle-jenkins-plugin.git'
            developerConnection 'scm:git@github.com/ghale/gradle-jenkins-plugin.git'
        }

        licenses {
            license {
                name 'The Apache Software License, Version 2.0'
                url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                distribution 'repo'
            }
        }

        developers {
            developer {
                id 'ghale'
                name 'Gary Hale'
                email 'ghhale@computer.org'
            }
        }
    }
}

pluginBundle {
    website = 'https://github.com/ghale/gradle-jenkins-plugin'
    vcsUrl = 'https://github.com/ghale/gradle-jenkins-plugin'
    description = 'A Gradle plugin for programmatically managing Jenkins instances.'
    tags = ['jenkins', 'gradle']

    plugins {
        jenkins {
            id = 'com.terrafolio.jenkins'
            displayName = 'Gradle Jenkins plugin'
        }
    }

    mavenCoordinates {
        groupId = project.group
        artifactId = project.name
        version = project.version
    }
}

apply from: "gradle/jenkinsIntegTest.gradle"


