Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 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, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | // Following Gradle best practices to keep build logic organized |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 21 | // ---------------------------------------------------------------------------- |
| 22 | // Compiler configuration details |
| 23 | |
Jiayu Liu | c4e96c7 | 2022-05-19 03:03:07 +0800 | [diff] [blame] | 24 | // We are using Java 11 toolchain to compile. |
| 25 | // This enables decoupling from the Java version that gradle runs, from |
| 26 | // the actual JDK version for the project. For more details, see |
| 27 | // https://docs.gradle.org/current/userguide/toolchains.html |
| 28 | // |
| 29 | // The '--release' option added below makes sure that even if we are using |
| 30 | // the toolchain version > 8, the final artifact is at version 8. There is |
| 31 | // also a runtime CI that's based on Java 8 to ensure that. |
| 32 | java { |
| 33 | toolchain { |
| 34 | languageVersion = JavaLanguageVersion.of(11) |
| 35 | } |
| 36 | } |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 37 | |
Jiayu Liu | c4e96c7 | 2022-05-19 03:03:07 +0800 | [diff] [blame] | 38 | tasks.withType(JavaCompile).configureEach { |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 39 | options.encoding = 'UTF-8' |
| 40 | options.debug = true |
| 41 | options.deprecation = true |
Christopher Tubbs | ebfa771 | 2021-02-04 14:13:24 -0500 | [diff] [blame] | 42 | // the following is to build with Java 8 specifications, even when building with JDK9 or later |
Jiayu Liu | c4e96c7 | 2022-05-19 03:03:07 +0800 | [diff] [blame] | 43 | options.release = 8 |
| 44 | options.compilerArgs += [ |
Jiayu Liu | 6bdefc4 | 2022-04-19 00:50:35 +0800 | [diff] [blame] | 45 | '-Werror', |
| 46 | '-Xlint:deprecation', |
| 47 | '-Xlint:cast', |
| 48 | '-Xlint:empty', |
| 49 | '-Xlint:fallthrough', |
| 50 | '-Xlint:finally', |
| 51 | '-Xlint:overrides', |
| 52 | // we can't enable -Xlint:unchecked just yet |
Jiayu Liu | c4e96c7 | 2022-05-19 03:03:07 +0800 | [diff] [blame] | 53 | ] |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 54 | } |
| 55 | |
Jiayu Liu | f31c588 | 2022-09-27 14:06:57 +0800 | [diff] [blame] | 56 | tasks.withType(Javadoc) { |
| 57 | failOnError false |
| 58 | options.addStringOption('Xdoclint:none', '-quiet') |
| 59 | options.addStringOption('encoding', 'UTF-8') |
| 60 | options.addStringOption('charSet', 'UTF-8') |
| 61 | } |
| 62 | |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 63 | // ---------------------------------------------------------------------------- |
| 64 | // Jar packaging details |
| 65 | processResources { |
| 66 | into('META-INF') { |
| 67 | from "$thriftRoot/LICENSE" |
| 68 | from "$thriftRoot/NOTICE" |
| 69 | rename('(.+)', '$1.txt') |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | jar { |
| 74 | project.test.dependsOn it |
| 75 | manifest { |
| 76 | attributes([ |
| 77 | "Implementation-Version": "${project.version}", |
Mark Raynsford | 22671db | 2020-10-21 20:01:40 +0000 | [diff] [blame] | 78 | "Automatic-Module-Name": "${project.group}", |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 79 | "Bundle-ManifestVersion": "2", |
| 80 | "Bundle-SymbolicName": "${project.group}", |
| 81 | "Bundle-Name": "Apache Thrift", |
| 82 | "Bundle-Version": "${project.version}", |
| 83 | "Bundle-Description": "Apache Thrift library", |
| 84 | "Bundle-License": "${project.license}", |
| 85 | "Bundle-ActivationPolicy": "lazy", |
Jiayu Liu | 5b15838 | 2022-05-12 00:20:37 +0800 | [diff] [blame] | 86 | "Export-Package": "${project.group}.async;uses:=\"${project.group}.protocol,${project.group}.transport,org.slf4j,${project.group}\";version=\"${archiveVersion}\",${project.group}.protocol;uses:=\"${project.group}.transport,${project.group},${project.group}.scheme\";version=\"${archiveVersion}\",${project.group}.server;uses:=\"${project.group}.transport,${project.group}.protocol,${project.group},org.slf4j,javax.servlet,javax.servlet.http\";version=\"${archiveVersion}\",${project.group}.transport;uses:=\"${project.group}.protocol,${project.group},org.apache.http.client,org.apache.http.params,org.apache.http.entity,org.apache.http.client.methods,org.apache.http,org.slf4j,javax.net.ssl,javax.net,javax.security.sasl,javax.security.auth.callback\";version=\"${archiveVersion}\",${project.group};uses:=\"${project.group}.protocol,${project.group}.async,${project.group}.server,${project.group}.transport,org.slf4j,org.apache.log4j,${project.group}.scheme\";version=\"${archiveVersion}\",${project.group}.meta_data;uses:=\"${project.group}\";version=\"${archiveVersion}\",${project.group}.scheme;uses:=\"${project.group}.protocol,${project.group}\";version=\"${archiveVersion}\",${project.group}.annotation;version=\"${archiveVersion}\"", |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 87 | "Import-Package": "javax.net,javax.net.ssl,javax.security.auth.callback,javax.security.sasl,javax.servlet;resolution:=optional,javax.servlet.http;resolution:=optional,org.slf4j;resolution:=optional;version=\"[1.4,2)\",org.apache.http.client;resolution:=optional,org.apache.http.params;resolution:=optional,org.apache.http.entity;resolution:=optional,org.apache.http.client.methods;resolution:=optional,org.apache.http;resolution:=optional" |
| 88 | ]) |
| 89 | } |
| 90 | } |