/*
 * jndn-mock
 * Copyright (c) 2016, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 3, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 */

buildscript {
  repositories {
    jcenter()
    mavenCentral()
  }
}

plugins {
  id "org.sonarqube" version "2.6.2"
  id 'net.saliman.cobertura' version '2.5.4'
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
//apply plugin: 'checkstyle'

// group = 'com.intel.jndn.mock'
group = 'net.named-data.jndn-extra'
version = '1.1.1'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
compileJava.options.encoding = 'UTF-8'

repositories {
  jcenter()
  mavenLocal()
  mavenCentral()
}

configurations {
  checkstyleConfig
}

dependencies {
  compile 'net.named-data:jndn:0.17'

  testCompile 'junit:junit:4.12'
  testRuntime 'org.slf4j:slf4j-api:1.7.25'

  checkstyleConfig "com.puppycrawl.tools:checkstyle:8.11"
}

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

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

tasks.withType(Test) {
  reports.html.destination = file("${reporting.baseDir}/${name}")
  testLogging {
    events "passed", "skipped", "failed"
    showStandardStreams = true
    exceptionFormat = "full"
  }
  outputs.upToDateWhen { false }
}

tasks.withType(Checkstyle) {
  checkstyleClasspath = project.configurations.checkstyleConfig
  checkstyleTest {
    configFile file('config/checkstyle/checkstyle-test.xml')
  }
}

if (JavaVersion.current().isJava8Compatible()) {
  allprojects {
    tasks.withType(Javadoc) {
      options.addStringOption('Xdoclint:none', '-quiet')
    }
  }
}

artifacts {
  archives javadocJar, sourcesJar
}

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

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

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

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

      pom.project {
        name 'jndn-mock'
        packaging 'jar'
        description 'Tools for testing NDN Java code without using network IO'
        url 'https://github.com/01org/jndn-mock'

        scm {
          connection 'scm:git:https://github.com/01org/jndn-mock'
          developerConnection 'scm:git:https://github.com/01org/jndn-mock'
          url 'https://github.com/01org/jndn-mock'
        }

        licenses {
          license {
            name 'GNU Lesser General Public License, Version 3.0+'
            url 'http://www.gnu.org/licenses/lgpl.html'
          }
        }

        developers {
          developer {
            id 'andrewbrown'
            name 'Andrew Brown'
            url 'https://github.com/andrewsbrown'
          }
          developer {
            id 'cawka'
            name 'Alexander Afanasyev'
            email 'aa@cs.ucla.edu'
          }
        }
      }
    }
  }
}

cobertura {
  coverageFormats = ['html', 'xml']
}
