/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

project(':') {
  apply plugin: 'base'
}

task sourceRelease(type: Tar) {
  // TODO: Add release signing: http://www.gradle.org/docs/current/userguide/signing_plugin.html

  description = "Build a source release, specifically excluding the build directories and gradle wrapper files"
  compression = Compression.GZIP

  baseName = "apache-samza-${project.version}-src"

  from(project.rootDir) {
    exclude '**/build'
    exclude 'build'
    exclude '.gradle'
    exclude 'gradlew'
    exclude 'gradlew.bat'
    exclude 'gradle/wrapper/gradle-wrapper.jar'
    exclude 'gradle/wrapper/gradle-wrapper.properties'
    exclude 'KEYS'
    exclude '.reviewboardrc'
  }

  into(baseName)

  // Set destination directory.
  destinationDir = file("${project.buildDir}/distribution/source")

  archiveName = "${baseName}.tgz"
  doLast { // generate md5 checksum
    ant.checksum file:"$destinationDir/$archiveName"
  }
}

// Publishing to Apache's Maven repository (Nexus). To test this locally, set
// repositoryUrl and snapshotRepositoryUrl below to 'file://localhost/tmp/myRepo'
subprojects {
  apply plugin: 'com.bmuschko.nexus'

  nexus {
    sign = true
    repositoryUrl = 'https://repository.apache.org/service/local/staging/deploy/maven2'
    snapshotRepositoryUrl = 'https://repository.apache.org/content/repositories/snapshots'
  }

  extraArchive {
    sources = true
    tests = false
    javadoc = true
  }

  modifyPom {
    project {
      name 'Apache Samza'
      description 'A distributed stream processing framework built upon Apache Kafka and Apache Hadoop YARN.'
      url 'http://samza.apache.org/'

      scm {
        url 'https://git-wip-us.apache.org/repos/asf?p=samza.git;a=tree'
        connection 'scm:http://git-wip-us.apache.org/repos/asf/samza.git'
        developerConnection 'scm:https://git-wip-us.apache.org/repos/asf/samza.git'
      }

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