buildscript {
  repositories {
    mavenCentral()
    maven {
      url 'https://plugins.gradle.org/m2/'
    }
  }
  dependencies {
    classpath 'com.cinnober.gradle:semver-git:2.2.1'
    classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.8'
  }
}

apply plugin: 'com.cinnober.gradle.semver-git'
apply plugin: 'idea'

allprojects {
  repositories {
    mavenCentral()
    mavenLocal()
  }
}

subprojects {
  apply plugin: 'java'
  apply plugin: 'idea'
  apply plugin: 'eclipse'
  apply plugin: 'net.ltgt.errorprone'

  // Set the same version for all sub-projects to root project version
  version = rootProject.version

  configurations.errorprone {
    resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.5'
  }

  plugins.withType(JavaPlugin) {
    sourceCompatibility = JavaVersion.VERSION_1_8

    // Set the Title and Version fields in the jar
    jar {
      manifest {
        attributes (
                'Implementation-Title': project.name,
                'Implementation-Version': project.version,
        )
      }
    }

    dependencies {
      testCompile('junit:junit:4.12')
    }
  }

  // Common distribution plugin settings for sub-modules
  plugins.withType(DistributionPlugin) {
    distTar {
      compression = Compression.GZIP
      extension = 'tar.gz'
    }
  }

  /**
   * Print test execution summary when informational logging is enabled.
   */
  test {
    testLogging {
      afterSuite { desc, result ->
        if (desc.getParent()) {
          logger.info desc.getName()
        } else {
          logger.info "Overall"
        }
        logger.info "  ${result.resultType} (" +
              "${result.testCount} tests, " +
              "${result.successfulTestCount} passed, " +
              "${result.failedTestCount} failed, " +
              "${result.skippedTestCount} skipped)"
      }
    }
  }
}

/**
 * Gradle wrapper task.
 */
task wrapper(type: Wrapper) {
  gradleVersion = '2.7'
}

idea {
  project {
    languageLevel = '1.8'
    vcs = 'Git'
  }
}
