blob: 0b2128a79998f6daed195f73c4b2d274be9dfcc1 [file] [log] [blame]
/*
* 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.
*/
plugins {
id 'base'
// Enable publishing build scans
id 'com.gradle.build-scan' version '2.1' apply false
// This plugin provides a task to determine which dependencies have updates.
// Additionally, the plugin checks for updates to Gradle itself.
//
// See https://github.com/ben-manes/gradle-versions-plugin for further details.
id 'com.github.ben-manes.versions' version '0.17.0'
// Apply one top level rat plugin to perform any required license enforcement analysis
id 'org.nosphere.apache.rat' version '0.4.0'
// Enable gradle-based release management
id 'net.researchgate.release' version '2.6.0'
id 'org.apache.beam.module'
id "org.sonarqube" version "2.7"
}
// Add performanceTest task to this build.gradle file
// so that running Performance tests using PerfKitBenchmarker is possible.
createPerformanceTestHarness()
/*************************************************************************************************/
// Configure the root project
// Plugins which require online access should not be enabled when running in offline mode.
if (!gradle.startParameter.isOffline()) {
apply plugin: "com.gradle.build-scan"
}
// JENKINS_HOME and BUILD_ID set automatically during Jenkins execution
def isCIBuild = ['JENKINS_HOME', 'BUILD_ID'].every System.&getenv
if (isCIBuild) {
buildScan {
// Build Scan enabled and TOS accepted for Jenkins lab build. This does not apply to builds on
// non-Jenkins machines. Developers need to separately enable and accept TOS to use build scans.
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
publishAlways()
}
}
rat {
// Set input directory to that of the root project instead of the CWD. This
// makes .gitignore rules (added below) work properly.
inputDir = project.rootDir
def exclusions = [
// Ignore files we track but do not distribute
"**/.github/**/*",
"**/package-list",
"**/test.avsc",
"**/user.avsc",
"**/test/resources/**/*.txt",
"**/test/**/.placeholder",
// Default eclipse excludes neglect subprojects
// Proto/grpc generated wrappers
"**/apache_beam/portability/api/*_pb2*.py",
"**/go/pkg/beam/**/*.pb.go",
// Ignore Go test data files
"**/go/data/**",
// VCF test files
"**/apache_beam/testing/data/vcf/*",
// JDBC package config files
"**/META-INF/services/java.sql.Driver",
// Ruby build files
"**/Gemfile.lock",
"**/Rakefile",
"**/.htaccess",
"website/src/_sass/_bootstrap.scss",
"website/src/_sass/bootstrap/**/*",
"website/src/js/bootstrap*.js",
"website/src/js/bootstrap/**/*",
// Ignore ownership files
"ownership/**/*",
"**/OWNERS",
// Json doesn't support comments.
"**/*.json",
]
// Add .gitignore excludes to the Apache Rat exclusion list. We re-create the behavior
// of the Apache Maven Rat plugin since the Apache Ant Rat plugin doesn't do this
// automatically.
def gitIgnore = project(':').file('.gitignore')
if (gitIgnore.exists()) {
def gitIgnoreExcludes = gitIgnore.readLines().findAll { !it.isEmpty() && !it.startsWith('#') }
exclusions.addAll(gitIgnoreExcludes)
}
failOnError = true
excludes = exclusions
}
check.dependsOn rat
// Define root pre/post commit tasks simplifying what is needed
// to be specified on the commandline when executing locally.
// This indirection also makes Jenkins use the branch of the PR
// for the test definitions.
task javaPreCommit() {
// We need to list the model/* builds since sdks/java/core doesn't
// depend on any of the model.
dependsOn ":beam-model-pipeline:build"
dependsOn ":beam-model-job-management:build"
dependsOn ":beam-model-fn-execution:build"
dependsOn ":beam-runners-google-cloud-dataflow-java-legacy-worker:build"
dependsOn ":beam-sdks-java-core:buildNeeded"
dependsOn ":beam-sdks-java-core:buildDependents"
dependsOn ":beam-examples-java:preCommit"
dependsOn ":beam-sdks-java-extensions-sql-jdbc:preCommit"
dependsOn ":beam-sdks-java-javadoc:allJavadoc"
dependsOn ":beam-runners-direct-java:needsRunnerTests"
}
task javaPreCommitPortabilityApi() {
dependsOn ":beam-runners-google-cloud-dataflow-java-fn-api-worker:build"
dependsOn ":beam-runners-google-cloud-dataflow-java-examples:verifyPortabilityApi"
}
task javaPostCommit() {
dependsOn ":beam-runners-google-cloud-dataflow-java:postCommit"
dependsOn ":beam-sdks-java-extensions-google-cloud-platform-core:postCommit"
dependsOn ":beam-sdks-java-io-google-cloud-platform:postCommit"
}
task sqlPostCommit() {
dependsOn ":beam-sdks-java-extensions-sql:postCommit"
dependsOn ":beam-sdks-java-extensions-sql-jdbc:postCommit"
}
task javaPostCommitPortabilityApi () {
dependsOn ":beam-runners-google-cloud-dataflow-java:postCommitPortabilityApi"
}
task goPreCommit() {
dependsOn ":beam-sdks-go:goTest"
dependsOn ":beam-sdks-go-examples:build"
dependsOn ":beam-sdks-go-test:build"
// Ensure all container Go boot code builds as well.
dependsOn ":beam-sdks-java-container:build"
dependsOn ":beam-sdks-python-container:build"
dependsOn ":beam-sdks-go-container:build"
}
task goPostCommit() {
dependsOn ":goIntegrationTests"
}
task goIntegrationTests() {
doLast {
exec {
executable 'sh'
args '-c', './sdks/go/test/run_integration_tests.sh'
}
}
dependsOn ":beam-sdks-go-test:build"
dependsOn ":beam-runners-google-cloud-dataflow-java-fn-api-worker:shadowJar"
}
task pythonPreCommit() {
dependsOn ":beam-sdks-python:preCommitPy2"
dependsOn ":beam-sdks-python-test-suites-tox-py35:preCommitPy35"
dependsOn ":beam-sdks-python-test-suites-tox-py36:preCommitPy36"
dependsOn ":beam-sdks-python-test-suites-tox-py37:preCommitPy37"
dependsOn ":beam-sdks-python-test-suites-dataflow:preCommitIT"
}
task pythonPostCommit() {
dependsOn ":beam-sdks-python:postCommit"
}
task python3PostCommit() {
dependsOn ":beam-sdks-python-test-suites-dataflow-py35:postCommitIT"
dependsOn ":beam-sdks-python-test-suites-dataflow-py36:postCommitIT"
dependsOn ":beam-sdks-python-test-suites-dataflow-py35:validatesRunnerBatchTests"
dependsOn ":beam-sdks-python-test-suites-direct-py35:postCommitIT"
dependsOn ":beam-sdks-python-test-suites-direct-py36:postCommitIT"
}
task portablePythonPreCommit() {
dependsOn ":beam-sdks-python:portablePreCommit"
}
task websitePreCommit() {
dependsOn ":beam-website:preCommit"
}
task communityMetricsPreCommit() {
dependsOn ":beam-test-infra-metrics:preCommit"
}
task communityMetricsProber() {
dependsOn ":beam-test-infra-metrics:checkProber"
}
task javaExamplesDataflowPrecommit() {
dependsOn ":beam-runners-google-cloud-dataflow-java-examples:preCommit"
dependsOn ":beam-runners-google-cloud-dataflow-java-examples-streaming:preCommit"
}
task runBeamDependencyCheck() {
dependsOn ":dependencyUpdates"
dependsOn ":beam-sdks-python:dependencyUpdates"
}
// Configure the release plugin to do only local work; the release manager determines what, if
// anything, to push. On failure, the release manager can reset the branch without pushing.
release {
revertOnFail = false
tagTemplate = 'v${version}'
git {
requireBranch = 'release-.*|master'
pushToRemote = ''
}
}