apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'

group = "com.github.ellzord"
archivesBaseName = "JALSE"
version = "1.1.11-SNAPSHOT"
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

sourceCompatibility = 1.8

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1'
    }
}

/*
 * http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html
 */
if (JavaVersion.current().isJava8Compatible()) {
    allprojects {
        tasks.withType(Javadoc) {
            options.addStringOption('Xdoclint:none', '-quiet')
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    testCompile 'junit:junit:4.12'
}

task javadocJar(type: Jar) {
    classifier = 'javadoc'
    from javadoc
}

task sourcesJar(type: Jar) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

artifacts {
    archives javadocJar, sourcesJar
}

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

signing {
    required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
    sign configurations.archives
}

jacocoTestReport {
    reports {
        xml.enabled = true
        html.enabled = true
    }
}

uploadArchives {
  repositories {
    mavenDeployer {
      beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

      repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
        authentication(userName: ossrhUsername, password: ossrhPassword)
      }

      snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
        authentication(userName: ossrhUsername, password: ossrhPassword)
      }

      pom.project {
        name 'JALSE'
        packaging 'jar'
        description 'Java Artificial Life Simulation Engine'
        url 'https://github.com/Ellzord/JALSE'

        scm {
          connection 'scm:git:git@github.com:Ellzord/JALSE.git'
          developerConnection 'scm:git:git@github.com:Ellzord/JALSE.git'
          url 'git@github.com:Ellzord/JALSE.git'
        }

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

        developers {
          developer {
            id 'Ellzord'
            name 'Elliot Ford'
          }
        }
      }
    }
  }
}
