blob: 214ac90b80aac4118e09e574e8d78a5476654774 [file] [log] [blame] [view]
Mark Slee54b7ab92007-03-06 00:06:27 +00001Thrift Java Software Library
2
Bryan Duxburydef30a62009-04-08 00:19:37 +00003License
4=======
5
6Licensed to the Apache Software Foundation (ASF) under one
7or more contributor license agreements. See the NOTICE file
8distributed with this work for additional information
9regarding copyright ownership. The ASF licenses this file
10to you under the Apache License, Version 2.0 (the
11"License"); you may not use this file except in compliance
12with the License. You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16Unless required by applicable law or agreed to in writing,
17software distributed under the License is distributed on an
18"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19KIND, either express or implied. See the License for the
20specific language governing permissions and limitations
21under the License.
Mark Slee54b7ab92007-03-06 00:06:27 +000022
Alex Volanis7004a612018-01-24 10:30:13 -050023Building and installing from source
24===================================
25
26When using a CMake build from the source distribution on Linux the
27easiest way to build and install is this simple command line:
28
29 make all && sudo make install/fast
30
31It is important to use the install/fast option to eliminate
32the automatic rebuild by dependency that causes issues because
33the build tooling is designed to work with cached files in the
34user home directory during the build process. Instead this builds
35the code in the expected local build tree and then uses CMake
36install code to copy to the target destination.
37
38Building Thrift with Gradle without CMake/Autoconf
39==================================================
Mark Slee54b7ab92007-03-06 00:06:27 +000040
41The Thrift Java source is not build using the GNU tools, but rather uses
Alex Volanis7004a612018-01-24 10:30:13 -050042the Gradle build system, which tends to be predominant amongst Java
Mark Slee54b7ab92007-03-06 00:06:27 +000043developers.
44
Jiayu Liu23b86362022-05-06 12:42:18 +080045Currently we use gradle 6.9.2 to build the Thrift Java source. The usual way to setup gradle
46project is to include the gradle-wrapper.jar in the project and then run the gradle wrapper to
47bootstrap setting up gradle binaries. However to avoid putting binary files into the source tree we
48have ignored the gradle wrapper files. You are expected to install it manually, as described in
49the [gradle documentation](https://docs.gradle.org/current/userguide/installation.html), or
50following this step (which is also done in the travis CI docker images):
51
52```bash
53export GRADLE_VERSION="6.9.2"
54# install dependencies
55apt-get install -y --no-install-recommends openjdk-11-jdk-headless wget unzip
56# download gradle distribution
57wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip
58# check binary integrity
59echo "8b356fd8702d5ffa2e066ed0be45a023a779bba4dd1a68fd11bc2a6bdc981e8f /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -
60# unzip and install
61unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip
62mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle
63ln -s /usr/local/gradle/bin/gradle /usr/local/bin
64```
65
66After the above step, `gradle` binary will be available in `/usr/local/bin/`. You can further choose
67to locally create the gradle wrapper (even if they are ignored) using:
68
69```bash
70gradle wrapper --gradle-version $GRADLE_VERSION
71```
72
Mark Slee54b7ab92007-03-06 00:06:27 +000073To compile the Java Thrift libraries, simply do the following:
74
Jiayu Liu23b86362022-05-06 12:42:18 +080075```bash
76gradle
77```
Mark Slee54b7ab92007-03-06 00:06:27 +000078
Jiayu Liu23b86362022-05-06 12:42:18 +080079Yep, that's easy. Look for `libthrift-<version>.jar` in the build/libs directory.
Alex Volanis7004a612018-01-24 10:30:13 -050080
81The default build will run the unit tests which expect a usable
82Thrift compiler to exist on the system. You have two choices for
83that.
84
85* Build the Thrift executable from source at the default
86 location in the source tree. The project is configured
87 to look for it there.
88* Install the published binary distribution to have Thrift
89 executable in a known location and add the path to the
90 ~/.gradle/gradle.properties file using the property name
91 "thrift.compiler". For example this would set the path in
92 a Windows box if Thrift was installed under C:\Thrift
93
94 thrift.compiler=C:/Thrift/thrift.exe
95
96To just build the library without running unit tests you simply do this.
97
Jiayu Liu23b86362022-05-06 12:42:18 +080098```bash
99gradle assemble
100```
Alex Volanis7004a612018-01-24 10:30:13 -0500101
102To install the library in the local Maven repository location
103where other Maven or Gradle builds can reference it simply do this.
104
Jiayu Liu23b86362022-05-06 12:42:18 +0800105```bash
106gradle install
107```
Alex Volanis7004a612018-01-24 10:30:13 -0500108
109The library will be placed in your home directory under .m2/repository
Mark Slee54b7ab92007-03-06 00:06:27 +0000110
111To include Thrift in your applications simply add libthrift.jar to your
112classpath, or install if in your default system classpath of choice.
113
Roger Meier6823b6d2012-01-24 19:35:09 +0000114
115Build Thrift behind a proxy:
116
Jiayu Liu23b86362022-05-06 12:42:18 +0800117
118```bash
119gradle -Dhttp.proxyHost=myproxyhost -Dhttp.proxyPort=8080 -Dhttp.proxyUser=thriftuser -Dhttp.proxyPassword=topsecret
120```
Roger Meier6823b6d2012-01-24 19:35:09 +0000121
122or via
123
Jiayu Liu23b86362022-05-06 12:42:18 +0800124```bash
125./configure --with-java GRADLE_OPTS='-Dhttp.proxyHost=myproxyhost -Dhttp.proxyPort=8080 -Dhttp.proxyUser=thriftuser -Dhttp.proxyPassword=topsecret'
126```
Alex Volanis7004a612018-01-24 10:30:13 -0500127
128Unit Test HTML Reports
129======================
130
131The build will automatically generate an HTML Unit Test report. This can be found
132under build/reports/tests/test/index.html. It can be viewed with a browser
133directly from that location.
134
135
136Clover Code Coverage for Thrift
137===============================
138
139The build will optionally generate Clover Code coverage if the Gradle property
140`cloverEnabled=true` is set in ~/.gradle/gradle.properties or on the command line
141via `-PcloverEnabled=true`. The generated report can be found under the location
142build/reports/clover/html/index.html. It can be viewed with a browser
143directly from that location. Additionally, a PDF report is generated and is found
144under the location build/reports/clover/clover.pdf.
145
146The following command will build, unit test, and generate Clover reports:
147
Jiayu Liu23b86362022-05-06 12:42:18 +0800148```bash
149gradle -PcloverEnabled=true
150```
Alex Volanis7004a612018-01-24 10:30:13 -0500151
152Publishing Maven Artifacts to Maven Central
153===========================================
154
155The Automake build generates a Makefile that provides the correct parameters
156when you run the build provided the configure.ac has been set with the correct
157version number. The Gradle build will receive the correct value for the build.
158The same applies to the CMake build, the value from the configure.ac file will
159be used if you execute these commands:
160
Jiayu Liu23b86362022-05-06 12:42:18 +0800161```bash
162make maven-publish -- This is for an Automake Linux build
163make MavenPublish -- This is for a CMake generated build
164```
Alex Volanis7004a612018-01-24 10:30:13 -0500165
166The uploadArchives task in Gradle is preconfigured with all necessary details
167to sign and publish the artifacts from the build to the Apache Maven staging
168repository. The task requires the following externally provided properties to
169authenticate to the repository and sign the artifacts. The preferred approach
170is to create or edit the ~/.gradle/gradle.properties file and add the following
171properties to it.
172
Jiayu Liu23b86362022-05-06 12:42:18 +0800173```properties
174# Signing key information for artifacts PGP signature (values are examples)
175signing.keyId=24875D73
176signing.password=secret
177signing.secretKeyRingFile=/Users/me/.gnupg/secring.gpg
Alex Volanis7004a612018-01-24 10:30:13 -0500178
Jiayu Liu23b86362022-05-06 12:42:18 +0800179# Apache Maven staging repository user credentials
180mavenUser=meMyselfAndI
181mavenPassword=MySuperAwesomeSecretPassword
182```
Alex Volanis7004a612018-01-24 10:30:13 -0500183
James E. King III98f379e2019-01-22 09:22:04 -0500184NOTE: If you do not have a secring.gpg file, see the
185[gradle signing docs](https://docs.gradle.org/current/userguide/signing_plugin.html)
186for instructions on how to generate it.
187
Alex Volanis7004a612018-01-24 10:30:13 -0500188It is also possible to manually publish using the Gradle build directly.
189With the key information and credentials in place the following will generate
190if needed the build artifacts and proceed to publish the results.
191
Jiayu Liu23b86362022-05-06 12:42:18 +0800192```bash
193gradle -Prelease=true uploadArchives
194```
Alex Volanis7004a612018-01-24 10:30:13 -0500195
196It is also possible to override the target repository for the Maven Publication
197by using a Gradle property, for example you can publish signed JAR files to your
198company internal server if you add this to the command line or in the
199~/.gradle/gradle.properties file. The URL below assumes a Nexus Repository.
200
Jiayu Liu23b86362022-05-06 12:42:18 +0800201```properties
202maven-repository-url=https://my.company.com/service/local/staging/deploy/maven2
203```
Alex Volanis7004a612018-01-24 10:30:13 -0500204
205Or the same on the command line:
206
Jiayu Liu23b86362022-05-06 12:42:18 +0800207```bash
208gradle -Pmaven-repository-url=https://my.company.com/service/local/staging/deploy/maven2 -Prelease=true -Pthrift.version=0.11.0 uploadArchives
209```
Roger Meier6823b6d2012-01-24 19:35:09 +0000210
211
Mark Slee54b7ab92007-03-06 00:06:27 +0000212Dependencies
213============
214
Alex Volanis7004a612018-01-24 10:30:13 -0500215Gradle
216http://gradle.org/
Beluga Behr9e813ae2018-12-31 10:58:19 -0500217
218# Breaking Changes
219
James E. King III178891f2019-07-08 06:49:15 -0400220## 0.13.0
Beluga Behre20ab3e2019-01-06 15:08:58 -0500221
Mithun RKc35ed732019-03-11 14:14:05 -0700222* The signature of the 'process' method in TAsyncProcessor and TProcessor has
James E. King III178891f2019-07-08 06:49:15 -0400223changed to remove the boolean return type and instead rely on Exceptions.
Beluga Behre20ab3e2019-01-06 15:08:58 -0500224
Mithun RKc35ed732019-03-11 14:14:05 -0700225* Per THRIFT-4805, TSaslTransportException has been removed. The same condition
226is now covered by TTansportException, where `TTransportException.getType() == END_OF_FILE`.
Jiayu Liu5d220eb2022-04-19 04:18:58 +0200227
Beluga Behr9e813ae2018-12-31 10:58:19 -0500228## 0.12.0
229
230The access modifier of the AutoExpandingBuffer class has been changed from
231public to default (package) and will no longer be accessible by third-party
232libraries.
233
Beluga Behr88584f82019-01-01 16:35:04 -0500234The access modifier of the ShortStack class has been changed from
235public to default (package) and will no longer be accessible by third-party
236libraries.
237