blob: 044a11433662c97f2ecf560e31efe1c9adab89dd [file] [log] [blame]
Alex Volanis7004a612018-01-24 10:30:13 -05001/*
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 Volanis7004a612018-01-24 10:30:13 -050021// ----------------------------------------------------------------------------
22// Compiler configuration details
23
Jiayu Liuc4e96c72022-05-19 03:03:07 +080024// 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.
32java {
33 toolchain {
34 languageVersion = JavaLanguageVersion.of(11)
35 }
36}
Alex Volanis7004a612018-01-24 10:30:13 -050037
Jiayu Liuc4e96c72022-05-19 03:03:07 +080038tasks.withType(JavaCompile).configureEach {
Alex Volanis7004a612018-01-24 10:30:13 -050039 options.encoding = 'UTF-8'
40 options.debug = true
41 options.deprecation = true
Christopher Tubbsebfa7712021-02-04 14:13:24 -050042 // the following is to build with Java 8 specifications, even when building with JDK9 or later
Jiayu Liuc4e96c72022-05-19 03:03:07 +080043 options.release = 8
44 options.compilerArgs += [
Jiayu Liu6bdefc42022-04-19 00:50:35 +080045 '-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 Liuc4e96c72022-05-19 03:03:07 +080053 ]
Alex Volanis7004a612018-01-24 10:30:13 -050054}
55
56// ----------------------------------------------------------------------------
57// Jar packaging details
58processResources {
59 into('META-INF') {
60 from "$thriftRoot/LICENSE"
61 from "$thriftRoot/NOTICE"
62 rename('(.+)', '$1.txt')
63 }
64}
65
66jar {
67 project.test.dependsOn it
68 manifest {
69 attributes([
70 "Implementation-Version": "${project.version}",
Mark Raynsford22671db2020-10-21 20:01:40 +000071 "Automatic-Module-Name": "${project.group}",
Alex Volanis7004a612018-01-24 10:30:13 -050072 "Bundle-ManifestVersion": "2",
73 "Bundle-SymbolicName": "${project.group}",
74 "Bundle-Name": "Apache Thrift",
75 "Bundle-Version": "${project.version}",
76 "Bundle-Description": "Apache Thrift library",
77 "Bundle-License": "${project.license}",
78 "Bundle-ActivationPolicy": "lazy",
Jiayu Liu5b158382022-05-12 00:20:37 +080079 "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 Volanis7004a612018-01-24 10:30:13 -050080 "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"
81 ])
82 }
83}