github.com/apache/beam/sdks/v2@v2.48.2/java/extensions/sql/jdbc/build.gradle (about)

     1  import groovy.json.JsonOutput
     2  
     3  /*
     4   * Licensed to the Apache Software Foundation (ASF) under one
     5   * or more contributor license agreements.  See the NOTICE file
     6   * distributed with this work for additional information
     7   * regarding copyright ownership.  The ASF licenses this file
     8   * to you under the Apache License, Version 2.0 (the
     9   * License); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *     http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing, software
    15   * distributed under the License is distributed on an AS IS BASIS,
    16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    17   * See the License for the specific language governing permissions and
    18   * limitations under the License.
    19   */
    20  
    21  plugins { id 'org.apache.beam.module' }
    22  applyJavaNature( automaticModuleName: 'org.apache.beam.sdk.extensions.sql.jdbc',
    23    exportJavadoc: false,
    24    testShadowJar: true,
    25    validateShadowJar: false,
    26    shadowClosure: {}
    27  )
    28  
    29  configurations {
    30    integrationTest
    31  }
    32  
    33  dependencies {
    34    implementation project(":sdks:java:extensions:sql")
    35    implementation "jline:jline:2.14.6"
    36    permitUnusedDeclared "jline:jline:2.14.6" // BEAM-11761
    37    implementation "sqlline:sqlline:1.4.0"
    38    implementation library.java.vendored_guava_26_0_jre
    39    implementation library.java.vendored_calcite_1_28_0
    40    permitUnusedDeclared library.java.vendored_calcite_1_28_0
    41    testImplementation project(path: ":sdks:java:io:google-cloud-platform", configuration: "testRuntimeMigration")
    42    testImplementation library.java.junit
    43    // Depending on outputs so integrationTest can run with only test dependencies.
    44    // This enables us to test the JDBC jar being loaded on a custom classloader.
    45    integrationTest sourceSets.test.output
    46    integrationTest sourceSets.main.output
    47    integrationTest library.java.junit
    48  }
    49  
    50  processResources {
    51    filter org.apache.tools.ant.filters.ReplaceTokens, tokens: [
    52            'beam.version': version,
    53    ]
    54  }
    55  
    56  shadowJar {
    57    manifest {
    58      attributes "Main-Class": "org.apache.beam.sdk.extensions.sql.jdbc.BeamSqlLine"
    59    }
    60  }
    61  
    62  test {}
    63  
    64  task shadowJarTest(type: Test, dependsOn: ":sdks:java:extensions:sql:jdbc:shadowJar") {
    65    group = "Verification"
    66  
    67    // Disable Gradle cache (it should not be used because the IT's won't run).
    68    outputs.upToDateWhen { false }
    69  
    70    systemProperty "driver.jar", configurations.shadowTestRuntimeClasspath[1]
    71  
    72    include '**/JdbcJarTest.class'
    73    classpath = configurations.integrationTest
    74    useJUnit { }
    75  }
    76  
    77  task endToEndTest(type: Test) {
    78    group = "Verification"
    79  
    80    def gcpProject = project.findProperty('gcpProject') ?: 'apache-beam-testing'
    81    def gcsTempRoot = project.findProperty('gcsTempRoot') ?: 'gs://temp-storage-for-end-to-end-tests/'
    82  
    83    // Disable Gradle cache (it should not be used because the IT's won't run).
    84    outputs.upToDateWhen { false }
    85  
    86    def pipelineOptions = [
    87            "--project=${gcpProject}",
    88            "--tempLocation=${gcsTempRoot}",
    89            "--blockOnRun=false"]
    90  
    91    systemProperty "beamTestPipelineOptions", JsonOutput.toJson(pipelineOptions)
    92  
    93    include '**/*IT.class'
    94    classpath = project(":sdks:java:extensions:sql:jdbc").sourceSets.test.runtimeClasspath
    95    testClassesDirs = files(project(":sdks:java:extensions:sql:jdbc").sourceSets.test.output.classesDirs)
    96    useJUnit { }
    97  }
    98  
    99  /* Define a common precommit task which depends on all the individual precommits. */
   100  task preCommit() {
   101    dependsOn "shadowJarTest"
   102  }
   103  
   104  /* Define a postcommit task which depends on integration tests. */
   105  task postCommit {
   106    group = "Verification"
   107    description = "Various integration tests"
   108    dependsOn endToEndTest
   109  }