plugins {
  id 'groovy'
  id 'java-gradle-plugin'
  id 'maven-publish'
  id 'com.palantir.git-version' version '0.10.1'
  id 'com.gradle.plugin-publish' version '0.11.0'
}

group = "com.lightbend.akka.grpc"
// https://github.com/palantir/gradle-git-version/issues/97

def tag = "git describe --tags".execute().text.substring(1).split("-g")[0].replace("\n", "")
def finalVersion = (tag == versionDetails().lastTag.substring(1)) ? tag : tag.reverse().reverse() + "-" + versionDetails().gitHash.substring(0, 8)

version = finalVersion

gradlePlugin {
  plugins {
    akkaGrpcPlugin {
      id = 'com.lightbend.akka.grpc.gradle'
      implementationClass = 'akka.grpc.gradle.AkkaGrpcPlugin'
    }
  }
}

pluginBundle {
  website = 'https://doc.akka.io/libraries/akka-grpc/current/'
  vcsUrl = 'https://github.com/akka/akka-grpc'
  description = 'Building streaming gRPC servers and clients on top of Akka Streams'
  tags = ['akka', 'streams', 'reactive']

  plugins {
    akkaGrpcPlugin {
      id = 'com.lightbend.akka.grpc.gradle'
      displayName = 'Akka gRPC'
    }
  }
}

jar {
  manifest {
    attributes 'Implementation-Version': project.version
  }
}

repositories {
  mavenCentral()
  maven {
    url "https://repo.akka.io/maven/github_actions"
  }
}

dependencies {
  implementation 'com.google.protobuf:protobuf-gradle-plugin:0.8.19'
  implementation 'commons-lang:commons-lang:2.6'
  testImplementation('org.spockframework:spock-core:1.3-groovy-2.5')
}

test {
  systemProperty 'akkaGrpcTest.pluginVersion', project.version
  testLogging {
    events "passed", "skipped", "failed"
    exceptionFormat "full"
    showStandardStreams = false
  }
}
