github.com/apache/beam/sdks/v2@v2.48.2/java/testing/jpms-tests/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 {
    22    id 'org.apache.beam.module'
    23  }
    24  javaVersion="1.11"
    25  applyJavaNature(
    26    exportJavadoc: false,
    27    publish: false,
    28    disableLintWarnings: ['requires-transitive-automatic', 'requires-automatic']
    29  )
    30  provideIntegrationTestingDependencies()
    31  enableJavaPerformanceTesting()
    32  
    33  description = "Apache Beam :: SDKs :: Java :: Testing :: JPMS Tests"
    34  ext.summary = "E2E test for Java 9 modules"
    35  
    36  // Java 17 needs compileJava to add-exports and add-opens for error prone
    37  if (project.hasProperty("compileAndRunTestsWithJava17")) {
    38    def java17Home = project.findProperty("java17Home")
    39    project.tasks.withType(JavaCompile) {
    40      options.fork = true
    41      options.forkOptions.javaHome = java17Home as File
    42      options.compilerArgs += ['-Xlint:-path']
    43      options.compilerArgs.addAll(['--release', '17'])
    44      // Error prone requires some packages to be exported/opened for Java 17
    45      // Disabling checks since this property is only used for Jenkins tests
    46      // https://github.com/tbroyer/gradle-errorprone-plugin#jdk-16-support
    47      options.errorprone.errorproneArgs.add("-XepDisableAllChecks")
    48      options.forkOptions.jvmArgs += [
    49              "-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
    50              "-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
    51              "-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
    52              "-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
    53              "-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
    54              "-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
    55              "-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
    56              "-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
    57              "-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
    58              "-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED"
    59      ]
    60    }
    61  }
    62  
    63  /*
    64   * List of runners to run integration tests on.
    65   */
    66  def testRunnerClass = [
    67          directRunnerIntegrationTest: "org.apache.beam.runners.direct.DirectRunner",
    68          flinkRunnerIntegrationTest: "org.apache.beam.runners.flink.TestFlinkRunner",
    69          dataflowRunnerIntegrationTest: "org.apache.beam.runners.dataflow.TestDataflowRunner",
    70          sparkRunnerIntegrationTest: "org.apache.beam.runners.spark.TestSparkRunner",
    71  ]
    72  
    73  configurations {
    74    baseIntegrationTest
    75    directRunnerIntegrationTest.extendsFrom(baseIntegrationTest)
    76    flinkRunnerIntegrationTest.extendsFrom(baseIntegrationTest)
    77    dataflowRunnerIntegrationTest.extendsFrom(baseIntegrationTest)
    78    sparkRunnerIntegrationTest.extendsFrom(baseIntegrationTest)
    79  }
    80  
    81  dependencies {
    82    implementation project(path: ":sdks:java:core", configuration: "shadow")
    83    implementation project(path: ":sdks:java:extensions:google-cloud-platform-core")
    84  
    85    testImplementation library.java.junit
    86    testImplementation library.java.hamcrest
    87  
    88    baseIntegrationTest project(path: ":sdks:java:testing:jpms-tests", configuration: "testRuntimeMigration")
    89    directRunnerIntegrationTest project(":runners:direct-java")
    90    flinkRunnerIntegrationTest project(":runners:flink:${project.ext.latestFlinkVersion}")
    91    dataflowRunnerIntegrationTest project(":runners:google-cloud-dataflow-java")
    92    sparkRunnerIntegrationTest project(":runners:spark:3")
    93  }
    94  
    95  /*
    96   * Create a ${runner}IntegrationTest task for each runner which runs a set
    97   * of integration tests for WordCount.
    98   */
    99  def gcpProject = project.findProperty('gcpProject') ?: 'apache-beam-testing'
   100  def gcpRegion = project.findProperty('gcpRegion') ?: 'us-central1'
   101  def gcsTempRoot = project.findProperty('gcsTempRoot') ?: 'gs://temp-storage-for-end-to-end-tests/'
   102  
   103  for (String runner : testRunnerClass.keySet()) {
   104    tasks.create(name: runner, type: Test) {
   105      def testPipelineOptions = [
   106              "--project=${gcpProject}",
   107              "--tempRoot=${gcsTempRoot}",
   108              "--runner=" + testRunnerClass[runner],
   109      ]
   110      if ("dataflowRunnerIntegrationTest".equals(runner)) {
   111        testPipelineOptions.add("--region=${gcpRegion}")
   112      }
   113      classpath = configurations."${runner}"
   114      include "**/*IT.class"
   115      maxParallelForks 4
   116      systemProperty "beamTestPipelineOptions", JsonOutput.toJson(testPipelineOptions)
   117    }
   118  }
   119  
   120  // Activate module support
   121  // https://docs.gradle.org/current/samples/sample_java_modules_multi_project.html
   122  plugins.withType(JavaPlugin).configureEach{
   123    java {
   124      modularity.inferModulePath = true
   125    }
   126  }
   127  
   128  // JPMS requires JDK > 8
   129  project.tasks.each {
   130    it.onlyIf {
   131      project.hasProperty("compileAndRunTestsWithJava17")
   132              || JavaVersion.VERSION_1_8.compareTo(JavaVersion.current()) < 0
   133    }
   134  }