| /* |
| * 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. |
| */ |
| |
| apply plugin: org.apache.beam.gradle.BeamModulePlugin |
| applyJavaNature() |
| |
| description = "Apache Beam :: SDKs :: Java :: Load Tests" |
| |
| |
| def mainClassProperty = "loadTest.mainClass" |
| def mainClass = project.findProperty(mainClassProperty) |
| |
| // When running via Gradle, this property can be used to pass commandline arguments |
| // to the nexmark launch |
| def loadTestArgsProperty = "loadTest.args" |
| def loadTestArgs = project.hasProperty(loadTestArgsProperty) ? |
| project.getProperty(loadTestArgsProperty).split() : [] |
| |
| // When running via Gradle, this property sets the runner dependency |
| def runnerProperty = "runner" |
| def runnerDependency = (project.hasProperty(runnerProperty) |
| ? project.getProperty(runnerProperty) |
| : ":beam-runners-direct-java") |
| |
| def shouldProvideSpark = ":beam-runners-spark".equals(runnerDependency) |
| |
| configurations { |
| // A configuration for running the Load testlauncher directly from Gradle, which |
| // uses Gradle to put the appropriate dependencies on the Classpath rather than |
| // bundling them into a fat jar |
| gradleRun |
| } |
| |
| dependencies { |
| shadow project(path: ":beam-sdks-java-core", configuration: "shadow") |
| shadow project(path: ":beam-runners-direct-java", configuration: "shadow") |
| shadow project(path: ":beam-sdks-java-io-synthetic", configuration: "shadow") |
| |
| gradleRun project(path: project.path, configuration: "shadow") |
| gradleRun project(path: runnerDependency, configuration: "shadow") |
| |
| // The Spark runner requires the user to provide a Spark dependency. For self-contained |
| // runs with the Spark runner, we can provide such a dependency. This is deliberately phrased |
| // to not hardcode any runner other than :beam-runners-direct-java |
| if (shouldProvideSpark) { |
| gradleRun library.java.spark_streaming |
| gradleRun library.java.spark_core, { |
| exclude group:"org.slf4j", module:"jul-to-slf4j" |
| } |
| } |
| } |
| |
| if (shouldProvideSpark) { |
| configurations.gradleRun { |
| // Using Spark runner causes a StackOverflowError if slf4j-jdk14 is on the classpath |
| exclude group: "org.slf4j", module: "slf4j-jdk14" |
| } |
| } |
| |
| task run(type: JavaExec) { |
| main = mainClass |
| classpath = configurations.gradleRun |
| args loadTestArgs |
| } |
| |