blob: 47f4ff0243045d76919595c244a618e86b776ce2 [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
Jiayu Liuf31c5882022-09-27 14:06:57 +080056tasks.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 Volanis7004a612018-01-24 10:30:13 -050063// ----------------------------------------------------------------------------
64// Jar packaging details
65processResources {
66 into('META-INF') {
67 from "$thriftRoot/LICENSE"
68 from "$thriftRoot/NOTICE"
69 rename('(.+)', '$1.txt')
70 }
71}
72
73jar {
74 project.test.dependsOn it
75 manifest {
76 attributes([
77 "Implementation-Version": "${project.version}",
Mark Raynsford22671db2020-10-21 20:01:40 +000078 "Automatic-Module-Name": "${project.group}",
Alex Volanis7004a612018-01-24 10:30:13 -050079 "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 Liu5b158382022-05-12 00:20:37 +080086 "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 -050087 "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}