From 05f05164c07756729332c3df18e478f4272a63f4 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Thu, 16 Apr 2020 16:55:05 -0400 Subject: [PATCH] Delete example-kotlin (#6936) --- .travis.yml | 1 - RELEASING.md | 2 - buildscripts/kokoro/android.sh | 3 - examples/README.md | 6 +- examples/example-kotlin/README.md | 62 ----------- .../android/helloworld/app/build.gradle | 81 -------------- .../android/helloworld/app/proguard-rules.pro | 17 --- .../app/src/main/AndroidManifest.xml | 22 ---- .../helloworldexample/HelloworldActivity.kt | 100 ------------------ .../app/src/main/proto/helloworld.proto | 37 ------- .../main/res/layout/activity_helloworld.xml | 54 ---------- .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 3418 -> 0 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 2206 -> 0 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 4842 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 7718 -> 0 bytes .../app/src/main/res/values/strings.xml | 3 - .../android/helloworld/build.gradle | 27 ----- .../android/helloworld/settings.gradle | 1 - examples/example-kotlin/build.gradle | 73 ------------- examples/example-kotlin/settings.gradle | 12 --- .../examples/helloworld/HelloWorldClient.kt | 83 --------------- .../examples/helloworld/HelloWorldServer.kt | 89 ---------------- .../src/main/proto/helloworld.proto | 37 ------- .../helloworld/HelloWorldClientTest.kt | 99 ----------------- .../helloworld/HelloWorldServerTest.kt | 72 ------------- 25 files changed, 1 insertion(+), 880 deletions(-) delete mode 100644 examples/example-kotlin/README.md delete mode 100644 examples/example-kotlin/android/helloworld/app/build.gradle delete mode 100644 examples/example-kotlin/android/helloworld/app/proguard-rules.pro delete mode 100644 examples/example-kotlin/android/helloworld/app/src/main/AndroidManifest.xml delete mode 100644 examples/example-kotlin/android/helloworld/app/src/main/kotlin/io/grpc/helloworldexample/HelloworldActivity.kt delete mode 100644 examples/example-kotlin/android/helloworld/app/src/main/proto/helloworld.proto delete mode 100644 examples/example-kotlin/android/helloworld/app/src/main/res/layout/activity_helloworld.xml delete mode 100644 examples/example-kotlin/android/helloworld/app/src/main/res/mipmap-hdpi/ic_launcher.png delete mode 100644 examples/example-kotlin/android/helloworld/app/src/main/res/mipmap-mdpi/ic_launcher.png delete mode 100644 examples/example-kotlin/android/helloworld/app/src/main/res/mipmap-xhdpi/ic_launcher.png delete mode 100644 examples/example-kotlin/android/helloworld/app/src/main/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 examples/example-kotlin/android/helloworld/app/src/main/res/values/strings.xml delete mode 100644 examples/example-kotlin/android/helloworld/build.gradle delete mode 100644 examples/example-kotlin/android/helloworld/settings.gradle delete mode 100644 examples/example-kotlin/build.gradle delete mode 100644 examples/example-kotlin/settings.gradle delete mode 100644 examples/example-kotlin/src/main/kotlin/io/grpc/examples/helloworld/HelloWorldClient.kt delete mode 100644 examples/example-kotlin/src/main/kotlin/io/grpc/examples/helloworld/HelloWorldServer.kt delete mode 100644 examples/example-kotlin/src/main/proto/helloworld.proto delete mode 100644 examples/example-kotlin/src/test/kotlin/io/grpc/examples/helloworld/HelloWorldClientTest.kt delete mode 100644 examples/example-kotlin/src/test/kotlin/io/grpc/examples/helloworld/HelloWorldServerTest.kt diff --git a/.travis.yml b/.travis.yml index c81d28675a38..4a37defdafbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,6 @@ install: - pushd examples/example-hostname && ../gradlew build && popd - pushd examples/example-hostname && mvn verify && popd - pushd examples/example-tls && ../gradlew clean build && popd - - pushd examples/example-kotlin && ../gradlew build && popd - pushd examples/example-xds && ../gradlew build && popd before_script: diff --git a/RELEASING.md b/RELEASING.md index 9d45bd9f5fed..1ed37a79059a 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -46,8 +46,6 @@ $ VERSION_FILES=( examples/example-jwt-auth/pom.xml examples/example-hostname/build.gradle examples/example-hostname/pom.xml - examples/example-kotlin/build.gradle - examples/example-kotlin/android/helloworld/app/build.gradle examples/example-tls/build.gradle examples/example-tls/pom.xml examples/example-xds/build.gradle diff --git a/buildscripts/kokoro/android.sh b/buildscripts/kokoro/android.sh index 9751c9aa433f..951488f747d6 100755 --- a/buildscripts/kokoro/android.sh +++ b/buildscripts/kokoro/android.sh @@ -56,9 +56,6 @@ cd ../routeguide cd ../helloworld ../../gradlew build -cd "$BASE_DIR/github/grpc-java/examples/example-kotlin/android/helloworld/" -../../../gradlew build - # Skip APK size and dex count comparisons for non-PR builds if [[ -z "${KOKORO_GITHUB_PULL_REQUEST_COMMIT:-}" ]]; then diff --git a/examples/README.md b/examples/README.md index fdcec2d636bb..9f74895a45ca 100644 --- a/examples/README.md +++ b/examples/README.md @@ -158,10 +158,6 @@ $ bazel-bin/hello-world-client - [JWT-based Authentication](example-jwt-auth) -- [Kotlin examples](example-kotlin) - -- [Kotlin Android examples](example-kotlin/android) - ## Unit test examples Examples for unit testing gRPC clients and servers are located in [examples/src/test](src/test). @@ -174,7 +170,7 @@ examples to write unit tests. `InProcessTransport` is light-weight and runs the and client in the same process without any socket/TCP connection. Mocking the client stub provides a false sense of security when writing tests. Mocking stubs and responses -allows for tests that don't map to reality, causing the tests to pass, but the system-under-test to fail. +allows for tests that don't map to reality, causing the tests to pass, but the system-under-test to fail. The gRPC client library is complicated, and accurately reproducing that complexity with mocks is very hard. You will be better off and write less code by using `InProcessTransport` instead. diff --git a/examples/example-kotlin/README.md b/examples/example-kotlin/README.md deleted file mode 100644 index 0f396a925f21..000000000000 --- a/examples/example-kotlin/README.md +++ /dev/null @@ -1,62 +0,0 @@ -grpc Kotlin example -============================================== - -The examples require grpc-java to already be built. You are strongly encouraged -to check out a git release tag, since there will already be a build of grpc -available. Otherwise you must follow COMPILING.md. - -You may want to read through the -[Quick Start Guide](https://grpc.io/docs/quickstart/java.html) -before trying out the examples. - -To build the examples, - -1. **[Install gRPC Java library SNAPSHOT locally, including code generation plugin](../../COMPILING.md) (Only need this step for non-released versions, e.g. master HEAD).** - -2. Run in this directory: -``` -$ ../gradlew installDist -``` - -This creates the scripts `hello-world-server`, `hello-world-client`, -`route-guide-server`, and `route-guide-client` in the -`build/install/examples/bin/` directory that run the examples. Each -example requires the server to be running before starting the client. - -For example, to try the hello world example first run: - -``` -$ ./build/install/examples/bin/hello-world-server -``` - -And in a different terminal window run: - -``` -$ ./build/install/examples/bin/hello-world-client -``` - -That's it! - -Please refer to gRPC Java's [README](../README.md) and -[tutorial](https://grpc.io/docs/tutorials/basic/java.html) for more -information. - -Unit test examples -============================================== - -Examples for unit testing gRPC clients and servers are located in [./src/test](./src/test). - -In general, we DO NOT allow overriding the client stub. -We encourage users to leverage `InProcessTransport` as demonstrated in the examples to -write unit tests. `InProcessTransport` is light-weight and runs the server -and client in the same process without any socket/TCP connection. - -For testing a gRPC client, create the client with a real stub -using an InProcessChannelBuilder.java and test it against an InProcessServer.java -with a mock/fake service implementation. - -For testing a gRPC server, create the server as an InProcessServer, -and test it against a real client stub with an InProcessChannel. - -The gRPC-java library also provides a JUnit rule, GrpcCleanupRule.java, to do the graceful shutdown -boilerplate for you. diff --git a/examples/example-kotlin/android/helloworld/app/build.gradle b/examples/example-kotlin/android/helloworld/app/build.gradle deleted file mode 100644 index 9558f1a06fe9..000000000000 --- a/examples/example-kotlin/android/helloworld/app/build.gradle +++ /dev/null @@ -1,81 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'com.google.protobuf' - -android { - compileSdkVersion 27 - - defaultConfig { - applicationId "io.grpc.helloworldexample" - // API level 14+ is required for TLS since Google Play Services v10.2 - minSdkVersion 14 - targetSdkVersion 27 - versionCode 1 - versionName "1.0" - } - buildTypes { - debug { minifyEnabled false } - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - lintOptions { - disable 'GoogleAppIndexingWarning', 'HardcodedText', 'InvalidPackage' - textReport true - textOutput "stdout" - } - // Android Studio 3.1 does not automatically pick up '/kotlin' as source input - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java.srcDirs += 'src/test/kotlin' - androidTest.java.srcDirs += 'src/androidTest/kotlin' - } - - lintOptions { - // Do not complain about outdated deps, so that this can javax.annotation-api can be same - // as other projects in this repo. Your project is not required to do this, and can - // upgrade the dep. - disable 'GradleDependency' - // The Android linter does not correctly detect resources used in Kotlin. - // See: - // - https://youtrack.jetbrains.com/issue/KT-7729 - // - https://youtrack.jetbrains.com/issue/KT-12499 - disable 'UnusedResources' - textReport true - textOutput "stdout" - } -} - -protobuf { - protoc { artifact = 'com.google.protobuf:protoc:3.11.0' } - plugins { - grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION - } - } - generateProtoTasks { - all().each { task -> - task.builtins { - java { option 'lite' } - } - task.plugins { - grpc { // Options added to --grpc_out - option 'lite' } - } - } - } -} - -dependencies { - implementation 'com.android.support:appcompat-v7:27.0.2' - implementation 'javax.annotation:javax.annotation-api:1.2' - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - - // You need to build grpc-java to obtain these libraries below. - implementation 'io.grpc:grpc-okhttp:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-protobuf-lite:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-stub:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION -} - -repositories { mavenCentral() } diff --git a/examples/example-kotlin/android/helloworld/app/proguard-rules.pro b/examples/example-kotlin/android/helloworld/app/proguard-rules.pro deleted file mode 100644 index 1507a526787e..000000000000 --- a/examples/example-kotlin/android/helloworld/app/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in $ANDROID_HOME/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - --dontwarn com.google.common.** -# Ignores: can't find referenced class javax.lang.model.element.Modifier --dontwarn com.google.errorprone.annotations.** --dontwarn javax.naming.** --dontwarn okio.** --dontwarn sun.misc.Unsafe diff --git a/examples/example-kotlin/android/helloworld/app/src/main/AndroidManifest.xml b/examples/example-kotlin/android/helloworld/app/src/main/AndroidManifest.xml deleted file mode 100644 index eee4057cd0cb..000000000000 --- a/examples/example-kotlin/android/helloworld/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/examples/example-kotlin/android/helloworld/app/src/main/kotlin/io/grpc/helloworldexample/HelloworldActivity.kt b/examples/example-kotlin/android/helloworld/app/src/main/kotlin/io/grpc/helloworldexample/HelloworldActivity.kt deleted file mode 100644 index 66c96b9bc610..000000000000 --- a/examples/example-kotlin/android/helloworld/app/src/main/kotlin/io/grpc/helloworldexample/HelloworldActivity.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2015 The gRPC Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.grpc.helloworldexample - -import android.app.Activity -import android.content.Context -import android.os.AsyncTask -import android.os.Bundle -import android.support.v7.app.AppCompatActivity -import android.text.TextUtils -import android.text.method.ScrollingMovementMethod -import android.view.View -import android.view.inputmethod.InputMethodManager -import android.widget.Button -import android.widget.TextView -import io.grpc.ManagedChannel -import io.grpc.ManagedChannelBuilder -import io.grpc.examples.helloworld.GreeterGrpc -import io.grpc.examples.helloworld.HelloRequest -import java.io.PrintWriter -import java.io.StringWriter -import java.lang.ref.WeakReference -import java.util.concurrent.TimeUnit -import kotlinx.android.synthetic.main.activity_helloworld.* - -class HelloworldActivity : AppCompatActivity(), View.OnClickListener { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_helloworld) - grpc_response_text!!.movementMethod = ScrollingMovementMethod() - send_button!!.setOnClickListener(this) - } - - override fun onClick(view: View) { - (getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager) - .hideSoftInputFromWindow(host_edit_text!!.windowToken, 0) - send_button!!.isEnabled = false - grpc_response_text!!.text = "" - GrpcTask(this) - .execute( - host_edit_text!!.text.toString(), - message_edit_text!!.text.toString(), - port_edit_text!!.text.toString()) - } - - private class GrpcTask constructor(activity: Activity) : AsyncTask() { - private val activityReference: WeakReference = WeakReference(activity) - private var channel: ManagedChannel? = null - - override fun doInBackground(vararg params: String): String { - val host = params[0] - val message = params[1] - val portStr = params[2] - val port = if (TextUtils.isEmpty(portStr)) 0 else Integer.valueOf(portStr) - return try { - channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build() - val stub = GreeterGrpc.newBlockingStub(channel) - val request = HelloRequest.newBuilder().setName(message).build() - val reply = stub.sayHello(request) - reply.message - } catch (e: Exception) { - val sw = StringWriter() - val pw = PrintWriter(sw) - e.printStackTrace(pw) - pw.flush() - - "Failed... : %s".format(sw) - } - } - - override fun onPostExecute(result: String) { - try { - channel?.shutdown()?.awaitTermination(1, TimeUnit.SECONDS) - } catch (e: InterruptedException) { - Thread.currentThread().interrupt() - } - - val activity = activityReference.get() ?: return - val resultText: TextView = activity.findViewById(R.id.grpc_response_text) - val sendButton: Button = activity.findViewById(R.id.send_button) - - resultText.text = result - sendButton.isEnabled = true - } - } -} diff --git a/examples/example-kotlin/android/helloworld/app/src/main/proto/helloworld.proto b/examples/example-kotlin/android/helloworld/app/src/main/proto/helloworld.proto deleted file mode 100644 index c60d9416f1fc..000000000000 --- a/examples/example-kotlin/android/helloworld/app/src/main/proto/helloworld.proto +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -syntax = "proto3"; - -option java_multiple_files = true; -option java_package = "io.grpc.examples.helloworld"; -option java_outer_classname = "HelloWorldProto"; -option objc_class_prefix = "HLW"; - -package helloworld; - -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; -} diff --git a/examples/example-kotlin/android/helloworld/app/src/main/res/layout/activity_helloworld.xml b/examples/example-kotlin/android/helloworld/app/src/main/res/layout/activity_helloworld.xml deleted file mode 100644 index e9f41f46696b..000000000000 --- a/examples/example-kotlin/android/helloworld/app/src/main/res/layout/activity_helloworld.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - -