github.com/apache/beam/sdks/v2@v2.48.2/java/io/google-cloud-platform/build.gradle (about)

     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one
     3   * or more contributor license agreements.  See the NOTICE file
     4   * distributed with this work for additional information
     5   * regarding copyright ownership.  The ASF licenses this file
     6   * to you under the Apache License, Version 2.0 (the
     7   * License); you may not use this file except in compliance
     8   * with the License.  You may obtain a copy of the License at
     9   *
    10   *     http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   * Unless required by applicable law or agreed to in writing, software
    13   * distributed under the License is distributed on an AS IS BASIS,
    14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15   * See the License for the specific language governing permissions and
    16   * limitations under the License.
    17   */
    18  
    19  import groovy.json.JsonOutput
    20  
    21  plugins { id 'org.apache.beam.module' }
    22  applyJavaNature(
    23    automaticModuleName: 'org.apache.beam.sdk.io.gcp',
    24    enableSpotbugs: false,
    25    classesTriggerCheckerBugs: [
    26      'PubSubPayloadTranslation': 'https://github.com/typetools/checker-framework/issues/3791',
    27    ],
    28  )
    29  
    30  description = "Apache Beam :: SDKs :: Java :: IO :: Google Cloud Platform"
    31  ext.summary = "IO library to read and write Google Cloud Platform systems from Beam."
    32  
    33  dependencies {
    34    implementation enforcedPlatform(library.java.google_cloud_platform_libraries_bom)
    35    permitUnusedDeclared enforcedPlatform(library.java.google_cloud_platform_libraries_bom)
    36    implementation project(path: ":model:pipeline", configuration: "shadow")
    37    implementation project(":runners:core-java")
    38    implementation project(path: ":sdks:java:core", configuration: "shadow")
    39    implementation project(":sdks:java:expansion-service")
    40    implementation project(":sdks:java:extensions:avro")
    41    permitUnusedDeclared project(":sdks:java:expansion-service") // BEAM-11761
    42    implementation project(":sdks:java:extensions:google-cloud-platform-core")
    43    implementation project(":sdks:java:extensions:protobuf")
    44    implementation project(":runners:core-construction-java")
    45    implementation project(":sdks:java:extensions:arrow")
    46    implementation library.java.avro
    47    implementation library.java.bigdataoss_util
    48    implementation library.java.error_prone_annotations
    49    implementation library.java.flogger_system_backend // Avoids conflicts with bigdataoss_util (BEAM-11010)
    50    permitUnusedDeclared library.java.flogger_system_backend // BEAM-11010
    51    implementation library.java.gax
    52    implementation(library.java.gax_grpc) {
    53      // BEAM-13781: gax-grpc's gRPC version was older than Beam declared
    54      exclude group: 'io.grpc', module: 'grpc-netty-shaded'
    55    }
    56    implementation library.java.gax_grpc_test
    57    implementation library.java.gax_httpjson
    58    permitUnusedDeclared library.java.gax_httpjson // BEAM-8755
    59    implementation library.java.google_api_client
    60    implementation library.java.google_api_common
    61    implementation library.java.google_api_services_bigquery
    62    implementation library.java.google_api_services_healthcare
    63    implementation library.java.google_api_services_pubsub
    64    implementation library.java.google_api_services_storage
    65    implementation library.java.google_auth_library_credentials
    66    implementation library.java.google_auth_library_oauth2_http
    67    implementation library.java.google_cloud_bigquery_storage
    68    implementation(library.java.google_cloud_bigtable_client_core_config)
    69    // google_cloud_bigtable_client_core declares old google-cloud-bigtable for
    70    // Java7 compatibility. The old google-cloud-bigtable is not compatible with
    71    // newer version of GAX. Declaring newer google-cloud-bigtable so that Beam
    72    // users receive newer google-cloud-bigtable. Beam doesn't directly use this
    73    // artifact.
    74    implementation library.java.google_cloud_bigtable
    75    permitUnusedDeclared library.java.google_cloud_bigtable
    76    implementation library.java.google_cloud_core
    77    implementation(library.java.google_cloud_core_grpc) {
    78      exclude group: 'io.grpc', module: 'grpc-core' // Use Beam's version
    79    }
    80    permitUnusedDeclared library.java.google_cloud_core_grpc // BEAM-11761
    81    implementation library.java.google_cloud_datastore_v1_proto_client
    82    implementation library.java.google_cloud_firestore
    83    implementation library.java.google_cloud_pubsublite
    84    // GCP PubSub client is used in TestPubSub
    85    implementation library.java.google_cloud_pubsub
    86    implementation library.java.google_cloud_spanner
    87    implementation library.java.google_code_gson
    88    implementation library.java.google_http_client
    89    implementation library.java.google_http_client_jackson2
    90    // bigdataoss_util declares old google_oauth_client version that does not have
    91    // IdTokenVerifier.verifyPayload method. Let's declare the newer one.
    92    implementation library.java.google_oauth_client
    93    permitUnusedDeclared library.java.google_oauth_client
    94    implementation library.java.grpc_alts
    95    permitUnusedDeclared library.java.grpc_alts // BEAM-11761
    96    implementation library.java.grpc_api
    97    implementation library.java.grpc_auth
    98    implementation library.java.grpc_core
    99    permitUnusedDeclared library.java.grpc_core // BEAM-11761
   100    implementation library.java.grpc_census
   101    permitUnusedDeclared library.java.grpc_census // BEAM-11761
   102    implementation library.java.grpc_context
   103    permitUnusedDeclared library.java.grpc_context // BEAM-11761
   104    implementation library.java.grpc_grpclb
   105    permitUnusedDeclared library.java.grpc_grpclb // BEAM-11761
   106    implementation library.java.grpc_netty
   107    implementation library.java.grpc_netty_shaded
   108    permitUnusedDeclared library.java.grpc_netty_shaded // BEAM-11761
   109    implementation library.java.grpc_protobuf
   110    implementation library.java.grpc_stub
   111    permitUnusedDeclared library.java.grpc_stub // BEAM-11761
   112    implementation library.java.grpc_xds
   113    permitUnusedDeclared library.java.grpc_xds // BEAM-11761
   114    implementation library.java.grpc_google_cloud_pubsub_v1
   115    implementation library.java.grpc_google_cloud_pubsublite_v1
   116    permitUnusedDeclared library.java.grpc_google_cloud_pubsublite_v1 // BEAM-11761
   117    implementation library.java.guava
   118    implementation library.java.http_client
   119    provided library.java.hamcrest
   120    permitUnusedDeclared library.java.hamcrest // BEAM-11761
   121    implementation library.java.http_core
   122    implementation library.java.jackson_core
   123    implementation library.java.jackson_databind
   124    implementation library.java.jackson_datatype_joda
   125    implementation library.java.jackson_datatype_jsr310
   126    implementation library.java.joda_time
   127    provided library.java.junit
   128    implementation library.java.netty_handler
   129    implementation library.java.netty_tcnative_boringssl_static
   130    permitUnusedDeclared library.java.netty_tcnative_boringssl_static // BEAM-11761
   131    implementation library.java.proto_google_cloud_bigquery_storage_v1
   132    implementation library.java.proto_google_cloud_bigtable_v2
   133    implementation library.java.proto_google_cloud_datastore_v1
   134    implementation library.java.proto_google_cloud_firestore_v1
   135    implementation library.java.proto_google_cloud_pubsub_v1
   136    implementation library.java.proto_google_cloud_pubsublite_v1
   137    implementation library.java.proto_google_cloud_spanner_admin_database_v1
   138    permitUnusedDeclared library.java.proto_google_cloud_spanner_admin_database_v1 // BEAM-11761
   139    implementation library.java.proto_google_cloud_spanner_v1
   140    implementation library.java.proto_google_common_protos
   141    implementation library.java.protobuf_java
   142    implementation library.java.protobuf_java_util
   143    implementation library.java.slf4j_api
   144    implementation library.java.vendored_grpc_1_54_0
   145    implementation library.java.vendored_guava_26_0_jre
   146    implementation library.java.arrow_memory_core
   147    implementation library.java.arrow_vector
   148  
   149    implementation 'com.google.http-client:google-http-client-gson:1.41.2'
   150    implementation "org.threeten:threetenbp:1.4.4"
   151  
   152    testImplementation library.java.arrow_memory_netty
   153    testImplementation project(path: ":sdks:java:core", configuration: "shadowTest")
   154    testImplementation project(path: ":sdks:java:extensions:avro", configuration: "testRuntimeMigration")
   155    testImplementation project(path: ":sdks:java:extensions:google-cloud-platform-core", configuration: "testRuntimeMigration")
   156    testImplementation project(path: ":sdks:java:extensions:protobuf", configuration: "testRuntimeMigration")
   157    testImplementation project(path: ":runners:direct-java", configuration: "shadow")
   158    testImplementation project(path: ":sdks:java:io:common", configuration: "testRuntimeMigration")
   159    testImplementation project(path: ":sdks:java:testing:test-utils", configuration: "testRuntimeMigration")
   160    testImplementation library.java.mockito_core
   161    testImplementation library.java.powermock
   162    testImplementation library.java.powermock_mockito
   163    testImplementation library.java.joda_time
   164    testImplementation library.java.google_cloud_spanner_test
   165    testImplementation library.java.google_cloud_bigtable_emulator
   166    testRuntimeOnly library.java.slf4j_jdk14
   167    // everit_json is needed for PubsubLite SchemaTransform tests that rely on JSON-schema translation.
   168    permitUnusedDeclared library.java.everit_json_schema
   169    provided library.java.everit_json_schema
   170  }
   171  
   172  // Don't pull in newer versions of the checker framework from dependencies.
   173  // TODO(BEAM-11125) Remove this when Beam upgrades to newest checker framework version.
   174  configurations.implementation {
   175    resolutionStrategy {
   176      force library.java.checker_qual
   177    }
   178  }
   179  
   180  /**
   181   * These are integration tests with the real Pubsub service and the DirectRunner.
   182   */
   183  task integrationTest(type: Test, dependsOn: processTestResources) {
   184    group = "Verification"
   185    def gcpProject = project.findProperty('gcpProject') ?: 'apache-beam-testing'
   186    def gcpTempRoot = project.findProperty('gcpTempRoot') ?: 'gs://temp-storage-for-end-to-end-tests'
   187    def firestoreDb = project.findProperty('firestoreDb') ?: 'firestoredb'
   188    systemProperty "beamTestPipelineOptions", JsonOutput.toJson([
   189            "--runner=DirectRunner",
   190            "--project=${gcpProject}",
   191            "--tempRoot=${gcpTempRoot}",
   192            "--firestoreDb=${firestoreDb}",
   193    ])
   194  
   195    // Disable Gradle cache: these ITs interact with live service that should always be considered "out of date"
   196    outputs.upToDateWhen { false }
   197  
   198    include '**/*IT.class'
   199    exclude '**/BigQueryIOReadIT.class'
   200    exclude '**/BigQueryIOStorageQueryIT.class'
   201    exclude '**/BigQueryIOStorageReadIT.class'
   202    exclude '**/BigQueryIOStorageReadTableRowIT.class'
   203    exclude '**/BigQueryIOStorageWriteIT.class'
   204    exclude '**/BigQueryToTableIT.class'
   205    exclude '**/BigQueryIOJsonTest.class'
   206  
   207    // Failing due to Firestore service-side changes
   208    // https://github.com/apache/beam/issues/25851
   209    exclude '**/firestore/it/**/*.class'
   210  
   211    maxParallelForks 4
   212    classpath = sourceSets.test.runtimeClasspath
   213    testClassesDirs = sourceSets.test.output.classesDirs
   214  
   215    useJUnit {
   216      excludeCategories "org.apache.beam.sdk.testing.UsesKms"
   217    }
   218  }
   219  
   220  task integrationTestKms(type: Test) {
   221    group = "Verification"
   222    def gcpProject = project.findProperty('gcpProject') ?: 'apache-beam-testing'
   223    def gcpTempRoot = project.findProperty('gcpTempRootKms') ?: 'gs://temp-storage-for-end-to-end-tests-cmek'
   224    def dataflowKmsKey = project.findProperty('dataflowKmsKey') ?: "projects/apache-beam-testing/locations/global/keyRings/beam-it/cryptoKeys/test"
   225    def firestoreDb = project.findProperty('firestoreDb') ?: 'firestoredb'
   226    systemProperty "beamTestPipelineOptions", JsonOutput.toJson([
   227            "--runner=DirectRunner",
   228            "--project=${gcpProject}",
   229            "--tempRoot=${gcpTempRoot}",
   230            "--dataflowKmsKey=${dataflowKmsKey}",
   231            "--firestoreDb=${firestoreDb}",
   232    ])
   233  
   234    // Disable Gradle cache: these ITs interact with live service that should always be considered "out of date"
   235    outputs.upToDateWhen { false }
   236  
   237    include '**/*IT.class'
   238    maxParallelForks 4
   239    classpath = sourceSets.test.runtimeClasspath
   240    testClassesDirs = sourceSets.test.output.classesDirs
   241    useJUnit {
   242      includeCategories "org.apache.beam.sdk.testing.UsesKms"
   243    }
   244  }
   245  
   246  // path(s) for Cloud Spanner related classes
   247  def spannerIncludes = [
   248          '**/org/apache/beam/sdk/io/gcp/spanner/**',
   249  ]
   250  
   251  // exclude auto-generated classes and integration tests
   252  def jacocoExcludes = [
   253          '**/AutoValue_*',
   254          '**/*IT*',
   255  ]
   256  
   257  task spannerCodeCoverageReport(type: JacocoReport, dependsOn: test) {
   258    group = "Reporting"
   259    description = "Generates code coverage report for Cloud Spanner related classes"
   260    classDirectories.setFrom(files(files(project.sourceSets.main.output).collect {
   261              project.fileTree(
   262                      dir: it,
   263                      includes: spannerIncludes,
   264                      excludes: jacocoExcludes)
   265    }))
   266    sourceDirectories.setFrom(files(project.sourceSets.main.allSource.srcDirs))
   267    executionData.setFrom(file("${buildDir}/jacoco/test.exec"))
   268    reports {
   269      html.enabled true
   270      html.destination file("${buildDir}/reports/jacoco/spanner/")
   271    }
   272  }
   273  
   274  task spannerCodeCoverageVerification(type: JacocoCoverageVerification, dependsOn: spannerCodeCoverageReport) {
   275    group = "Verification"
   276    description = "Enforces code coverage verification for Cloud Spanner related classes"
   277    classDirectories.setFrom(files(files(project.sourceSets.main.output).collect {
   278      project.fileTree(
   279              dir: it,
   280              includes: spannerIncludes,
   281              excludes: jacocoExcludes)
   282    }))
   283    sourceDirectories.setFrom(files(project.sourceSets.main.allSource.srcDirs))
   284    executionData.setFrom(file("${buildDir}/jacoco/test.exec"))
   285    violationRules {
   286      failOnViolation = true
   287      rule {
   288        element = 'BUNDLE'
   289  
   290        limit {
   291          value = 'COVEREDRATIO'
   292          counter = 'INSTRUCTION'
   293          minimum = 0.60
   294        }
   295      }
   296    }
   297  }
   298  
   299  // make the check task depend on spannerCodeCoverageVerification so that the build
   300  // fails when the code coverage threshold is violated.
   301  project.check.dependsOn "spannerCodeCoverageVerification"
   302  
   303  task postCommit {
   304    group = "Verification"
   305    description = "Integration tests of GCP connectors using the DirectRunner."
   306    dependsOn integrationTest
   307    dependsOn integrationTestKms
   308  }