import nebula.plugin.release.git.opinion.Strategies

plugins {
  id 'idea'

  id "de.marcphilipp.nexus-publish" version "0.4.0" apply false
  id "io.codearte.nexus-staging" version "0.22.0"
  id "nebula.release" version "15.3.0"

  id 'org.gradle.test-retry' version '1.2.0' apply false

  id 'org.unbroken-dome.test-sets' version '3.0.1' apply false
  id 'com.github.ben-manes.versions' version '0.27.0'

  id 'com.dorongold.task-tree' version '1.5'

  id "com.github.johnrengelman.shadow" version "6.1.0" apply false

  id "com.diffplug.spotless" version "5.8.2"
  id "com.github.spotbugs" version "4.6.0" apply false

  id "net.ltgt.errorprone" version "1.3.0" apply false
}

release {
  defaultVersionStrategy = Strategies.SNAPSHOT
}

nebulaRelease {
  addReleaseBranchPattern(/v\d+\.\d+\.x/)
}

nexusStaging {
  packageGroup = "io.opentelemetry"
  username = System.getenv('SONATYPE_USER')
  password = System.getenv('SONATYPE_KEY')

  // We have many artifacts so Maven Central takes a long time on its compliance checks. This sets
  // the timeout for waiting for the repository to close to a comfortable 50 minutes.
  numberOfRetries = 300
  delayBetweenRetriesInMillis = 10000
}

// Enable after verifying Maven Central publishing once through manual closing
// tasks.release.finalizedBy tasks.closeAndReleaseRepository

allprojects {
  apply from: "$rootDir/gradle/dependencies.gradle"
  apply from: "$rootDir/gradle/util.gradle"
}

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

description = 'OpenTelemetry instrumentations for Java'

allprojects {
  apply plugin: 'idea'

  idea {
    module {
      downloadJavadoc = false
      downloadSources = false
    }
  }
}

apply plugin: 'com.diffplug.spotless'

spotless {
  // this formatting is applied at the root level, as some of these files are not in a submodules
  // and would be missed otherwise
  format 'misc', {
    target '.gitignore', '*.md', 'docs/**/*.md'
    indentWithSpaces()
    trimTrailingWhitespace()
    endWithNewline()
  }
}

task formatCode(dependsOn: ['spotlessApply'])
check.dependsOn 'spotlessCheck'
