Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THRIFT-5570: update java lib document about gradle usage #2583

Merged
merged 3 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ project.lock.json
/lib/js/dist
/lib/js/doc
/lib/js/test/build
/lib/kotlin/cross-test-client/build/
/lib/kotlin/cross-test-server/build/
/lib/kotlin/build/
/lib/kotlin/.gradle/
/lib/kotlin/gradle/
/lib/kotlin/gradlew
/lib/kotlin/gradlew.bat
/lib/netstd/**/bin
/lib/netstd/**/obj
/lib/nodejs/coverage
Expand Down
2 changes: 1 addition & 1 deletion build/cmake/FindGradle.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# GRADLE_FOUND - system has Gradle
# GRADLE_EXECUTABLE - the Gradle executable
#
# It will search the environment variable ANT_HOME if it is set
# It will search the environment variable GRADLE_HOME if it is set

include(FindPackageHandleStandardArgs)

Expand Down
4 changes: 2 additions & 2 deletions doc/install/debian.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Debian 7/Ubuntu 12 users need to manually install a more recent version of autom
If you would like to build Apache Thrift libraries for other programming languages you may need to install additional packages. The following languages require the specified additional packages:

* Java
* packages: gradle
* packages: gradle (version 6.9.2)
* You will also need Java JDK v1.8 or higher. Type **javac** to see a list of available packages, pick the one you prefer and **apt-get install** it (e.g. default-jdk).
* Ruby
* ruby-full ruby-dev ruby-rspec rake rubygems bundler
Expand Down Expand Up @@ -51,7 +51,7 @@ If you would like to build Apache Thrift libraries for other programming languag
* dart & pub
* https://www.dartlang.org/install/linux
* https://www.dartlang.org/tools/pub/installing


## Additional reading

Expand Down
12 changes: 6 additions & 6 deletions lib/java/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,38 @@
export CLASSPATH

all-local:
gradle $(GRADLE_OPTS) assemble \
$(GRADLE) $(GRADLE_OPTS) assemble \
-Prelease=true \
-Pthrift.version=$(PACKAGE_VERSION) \
--console=plain

install-exec-hook:
gradle $(GRADLE_OPTS) install \
$(GRADLE) $(GRADLE_OPTS) install \
-Prelease=true \
-Pinstall.path=$(DESTDIR)$(JAVA_PREFIX) \
-Pinstall.javadoc.path=$(DESTDIR)$(docdir)/java \
-Pthrift.version=$(PACKAGE_VERSION) \
--console=plain

clean-local:
gradle $(GRADLE_OPTS) clean --console=plain
$(GRADLE) $(GRADLE_OPTS) clean --console=plain

precross: $(THRIFT)
gradle $(GRADLE_OPTS) shadowJar \
$(GRADLE) $(GRADLE_OPTS) shadowJar \
-Prelease=true \
-Pthrift.version=$(PACKAGE_VERSION) \
-Pthrift.compiler=$(THRIFT) \
--console=plain

check-local: $(THRIFT)
gradle $(GRADLE_OPTS) test \
$(GRADLE) $(GRADLE_OPTS) test \
-Prelease=true \
-Pthrift.version=$(PACKAGE_VERSION) \
-Pthrift.compiler=$(THRIFT) \
--console=plain

maven-publish:
gradle $(GRADLE_OPTS) uploadArchives \
$(GRADLE) $(GRADLE_OPTS) uploadArchives \
-Prelease=true \
-Pthrift.version=$(PACKAGE_VERSION) \
--console=plain
Expand Down
91 changes: 70 additions & 21 deletions lib/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,41 @@ The Thrift Java source is not build using the GNU tools, but rather uses
the Gradle build system, which tends to be predominant amongst Java
developers.

Currently we use gradle 6.9.2 to build the Thrift Java source. The usual way to setup gradle
project is to include the gradle-wrapper.jar in the project and then run the gradle wrapper to
bootstrap setting up gradle binaries. However to avoid putting binary files into the source tree we
have ignored the gradle wrapper files. You are expected to install it manually, as described in
the [gradle documentation](https://docs.gradle.org/current/userguide/installation.html), or
following this step (which is also done in the travis CI docker images):

```bash
export GRADLE_VERSION="6.9.2"
# install dependencies
apt-get install -y --no-install-recommends openjdk-11-jdk-headless wget unzip
# download gradle distribution
wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip
# check binary integrity
echo "8b356fd8702d5ffa2e066ed0be45a023a779bba4dd1a68fd11bc2a6bdc981e8f /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -
# unzip and install
unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip
mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle
ln -s /usr/local/gradle/bin/gradle /usr/local/bin
```

After the above step, `gradle` binary will be available in `/usr/local/bin/`. You can further choose
to locally create the gradle wrapper (even if they are ignored) using:

```bash
gradle wrapper --gradle-version $GRADLE_VERSION
```

To compile the Java Thrift libraries, simply do the following:

gradle
```bash
gradle
```

Yep, that's easy. Look for libthrift-<version>.jar in the build/libs directory.
Yep, that's easy. Look for `libthrift-<version>.jar` in the build/libs directory.

The default build will run the unit tests which expect a usable
Thrift compiler to exist on the system. You have two choices for
Expand All @@ -65,12 +95,16 @@ that.

To just build the library without running unit tests you simply do this.

gradle assemble
```bash
gradle assemble
```

To install the library in the local Maven repository location
where other Maven or Gradle builds can reference it simply do this.

gradle install
```bash
gradle install
```

The library will be placed in your home directory under .m2/repository

Expand All @@ -80,12 +114,16 @@ classpath, or install if in your default system classpath of choice.

Build Thrift behind a proxy:

gradle -Dhttp.proxyHost=myproxyhost -Dhttp.proxyPort=8080 -Dhttp.proxyUser=thriftuser -Dhttp.proxyPassword=topsecret

or via
```bash
gradle -Dhttp.proxyHost=myproxyhost -Dhttp.proxyPort=8080 -Dhttp.proxyUser=thriftuser -Dhttp.proxyPassword=topsecret
```

./configure --with-java GRADLE_OPTS='-Dhttp.proxyHost=myproxyhost -Dhttp.proxyPort=8080 -Dhttp.proxyUser=thriftuser -Dhttp.proxyPassword=topsecret'
or via

```bash
./configure --with-java GRADLE_OPTS='-Dhttp.proxyHost=myproxyhost -Dhttp.proxyPort=8080 -Dhttp.proxyUser=thriftuser -Dhttp.proxyPassword=topsecret'
```

Unit Test HTML Reports
======================
Expand All @@ -107,8 +145,9 @@ under the location build/reports/clover/clover.pdf.

The following command will build, unit test, and generate Clover reports:

gradle -PcloverEnabled=true

```bash
gradle -PcloverEnabled=true
```

Publishing Maven Artifacts to Maven Central
===========================================
Expand All @@ -119,8 +158,10 @@ version number. The Gradle build will receive the correct value for the build.
The same applies to the CMake build, the value from the configure.ac file will
be used if you execute these commands:

make maven-publish -- This is for an Automake Linux build
make MavenPublish -- This is for a CMake generated build
```bash
make maven-publish -- This is for an Automake Linux build
make MavenPublish -- This is for a CMake generated build
```

The uploadArchives task in Gradle is preconfigured with all necessary details
to sign and publish the artifacts from the build to the Apache Maven staging
Expand All @@ -129,14 +170,16 @@ authenticate to the repository and sign the artifacts. The preferred approach
is to create or edit the ~/.gradle/gradle.properties file and add the following
properties to it.

# Signing key information for artifacts PGP signature (values are examples)
signing.keyId=24875D73
signing.password=secret
signing.secretKeyRingFile=/Users/me/.gnupg/secring.gpg
```properties
# Signing key information for artifacts PGP signature (values are examples)
signing.keyId=24875D73
signing.password=secret
signing.secretKeyRingFile=/Users/me/.gnupg/secring.gpg

# Apache Maven staging repository user credentials
mavenUser=meMyselfAndI
mavenPassword=MySuperAwesomeSecretPassword
# Apache Maven staging repository user credentials
mavenUser=meMyselfAndI
mavenPassword=MySuperAwesomeSecretPassword
```

NOTE: If you do not have a secring.gpg file, see the
[gradle signing docs](https://docs.gradle.org/current/userguide/signing_plugin.html)
Expand All @@ -146,18 +189,24 @@ It is also possible to manually publish using the Gradle build directly.
With the key information and credentials in place the following will generate
if needed the build artifacts and proceed to publish the results.

gradle -Prelease=true uploadArchives
```bash
gradle -Prelease=true uploadArchives
```

It is also possible to override the target repository for the Maven Publication
by using a Gradle property, for example you can publish signed JAR files to your
company internal server if you add this to the command line or in the
~/.gradle/gradle.properties file. The URL below assumes a Nexus Repository.

maven-repository-url=https://my.company.com/service/local/staging/deploy/maven2
```properties
maven-repository-url=https://my.company.com/service/local/staging/deploy/maven2
```

Or the same on the command line:

gradle -Pmaven-repository-url=https://my.company.com/service/local/staging/deploy/maven2 -Prelease=true -Pthrift.version=0.11.0 uploadArchives
```bash
gradle -Pmaven-repository-url=https://my.company.com/service/local/staging/deploy/maven2 -Prelease=true -Pthrift.version=0.11.0 uploadArchives
```


Dependencies
Expand Down
78 changes: 0 additions & 78 deletions lib/kotlin/.gitignore

This file was deleted.