| /* |
| * 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. |
| */ |
| |
| buildscript { |
| dependencies { |
| classpath(group: 'com.github.jengelman.gradle.plugins', name: 'shadow', version: '6.1.0') |
| } |
| } |
| |
| plugins { |
| id 'java' |
| id 'java-library' |
| id 'com.github.johnrengelman.shadow' version '5.1.0' |
| } |
| |
| ext.scalaLabel = System.getenv("SCALA_VERSION") ?: "${scala}" |
| println("Scala version: ${ext.scalaLabel}") |
| |
| ext.sparkLabel = (System.getenv("SPARK_VERSION") ?: "${spark}").split(/\./)[0] |
| println("Spark version: ${ext.sparkLabel}") |
| |
| ext.jdkLabel = System.getenv("JDK_VERSION") ?: "${analyticsJDKLevel}" |
| println("Java source/target compatibility level: ${ext.jdkLabel}") |
| |
| def profile = "profiles/scala-${ext.scalaLabel}-spark-${ext.sparkLabel}-jdk-${ext.jdkLabel}.gradle" |
| if (!file(profile).exists()) { |
| throw new InvalidUserDataException("Profile ${profile} does not exist, which indicates this combination of Scala, Spark, and Java is unsupported.\n" + |
| "Please either add an appropriate profile if this combination should work, or use a different one.") |
| } |
| |
| println("Using profile ${profile}") |
| apply(from: profile) |
| |
| apply(plugin: 'idea') |
| |
| task copyCodeStyle(type: Copy) { |
| from('ide/idea/codeStyleSettings.xml') |
| into('.idea') |
| } |
| |
| tasks.idea.dependsOn(tasks.copyCodeStyle) |
| |
| task copyInspections(type: Copy) { |
| from('ide/idea/Project_Default.xml') |
| into('.idea/inspectionProfiles') |
| } |
| tasks.idea.dependsOn(tasks.copyInspections) |
| |
| subprojects { |
| apply(plugin: 'java-library') |
| apply(plugin: 'checkstyle') |
| |
| sourceCompatibility = "${project.rootProject.ext.jdkLabel}" |
| targetCompatibility = "${project.rootProject.ext.jdkLabel}" |
| |
| tasks.withType(JavaCompile) { |
| if ("${project.rootProject.ext.jdkLabel}" == '1.8') { |
| // Unfortunately, we can't use release here. We can only use public APIs when using release. |
| // org.apache.cassandra.spark.bulkwriter.util.FastByteOperations uses sun.misc.Unsafe which is causing the build |
| // to fail. |
| options.compilerArgs += ['-source', '8', '-target', '8'] |
| } else { |
| options.release = 11 |
| } |
| } |
| |
| archivesBaseName = "${project.name}" |
| if ("${project.rootProject.ext.sparkLabel}" == '3') { |
| archivesBaseName = "${archivesBaseName}_spark3" |
| } |
| archivesBaseName = "${archivesBaseName}_${scalaMajorVersion}" |
| |
| if ("${project.rootProject.ext.jdkLabel}" == '1.8') { |
| if ("${version}".contains('-SNAPSHOT')) { |
| version = "${version}".replace('-SNAPSHOT', '-jdk8-SNAPSHOT') |
| } else { |
| version = "${version}-jdk8" |
| } |
| } |
| |
| repositories { |
| // uncomment the line below for local development |
| mavenLocal() |
| } |
| |
| dependencies { |
| compileOnly(group: 'com.intellij', name: 'annotations', version: "${project.rootProject.intellijVersion}") |
| testCompileOnly(group: 'com.intellij', name: 'annotations', version: "${project.rootProject.intellijVersion}") |
| } |
| |
| sourceSets { |
| main { |
| java { |
| srcDirs += ["src/main/spark${project.rootProject.ext.sparkLabel}", |
| "src/main/scala-${scalaMajorVersion}-spark-${sparkMajorVersion}"] |
| } |
| } |
| test { |
| java { |
| srcDirs += ["src/test/spark${project.rootProject.ext.sparkLabel}", |
| "src/test/scala-${scalaMajorVersion}-spark-${sparkMajorVersion}"] |
| } |
| } |
| } |
| |
| test { |
| if (JavaVersion.current().isJava11Compatible()) { |
| def JDK11_OPTIONS = ['-Djdk.attach.allowAttachSelf=true', |
| '--add-exports', 'java.base/jdk.internal.misc=ALL-UNNAMED', |
| '--add-exports', 'java.base/jdk.internal.ref=ALL-UNNAMED', |
| '--add-exports', 'java.base/sun.nio.ch=ALL-UNNAMED', |
| '--add-exports', 'java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED', |
| '--add-exports', 'java.rmi/sun.rmi.registry=ALL-UNNAMED', |
| '--add-exports', 'java.rmi/sun.rmi.server=ALL-UNNAMED', |
| '--add-exports', 'java.sql/java.sql=ALL-UNNAMED', |
| '--add-opens', 'java.base/java.lang.module=ALL-UNNAMED', |
| '--add-opens', 'java.base/jdk.internal.loader=ALL-UNNAMED', |
| '--add-opens', 'java.base/jdk.internal.ref=ALL-UNNAMED', |
| '--add-opens', 'java.base/jdk.internal.reflect=ALL-UNNAMED', |
| '--add-opens', 'java.base/jdk.internal.math=ALL-UNNAMED', |
| '--add-opens', 'java.base/jdk.internal.module=ALL-UNNAMED', |
| '--add-opens', 'java.base/jdk.internal.util.jar=ALL-UNNAMED', |
| '--add-opens', 'jdk.management/com.sun.management.internal=ALL-UNNAMED'] |
| jvmArgs(JDK11_OPTIONS) |
| println("JVM arguments for $project.name are $allJvmArgs") |
| } |
| } |
| } |