From 540b4d35212880b392006171280132f4842e98b5 Mon Sep 17 00:00:00 2001 From: Louis Ryan Date: Fri, 4 Sep 2015 13:26:24 -0700 Subject: [PATCH] Revert "Draft of Android specific Channe builder" This reverts commit d6dc790f05c90ffba2c7a4356121ae4d586e467e. --- .travis.yml | 9 +- android-interop-testing/app/build.gradle | 17 +- android-interop-testing/build.gradle | 1 - android/build.gradle | 27 ---- android/delegate.gradle | 151 ------------------ .../android/AndroidChannelBuilderTest.java | 56 ------- android/src/main/AndroidManifest.xml | 34 ---- .../grpc/android/AndroidChannelBuilder.java | 139 ---------------- build.gradle | 7 +- settings.gradle | 2 - version.properties | 1 - 11 files changed, 10 insertions(+), 434 deletions(-) delete mode 100644 android/build.gradle delete mode 100644 android/delegate.gradle delete mode 100644 android/src/androidTest/java/io/grpc/android/AndroidChannelBuilderTest.java delete mode 100644 android/src/main/AndroidManifest.xml delete mode 100644 android/src/main/java/io/grpc/android/AndroidChannelBuilder.java delete mode 100644 version.properties diff --git a/.travis.yml b/.travis.yml index f501c22572..b25e182ba3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,6 @@ sudo: false -language: android - -android: - components: - - build-tools-21.1.1 # preinstalled in travis env - - android-21 - -script: ./gradlew build +language: java env: global: diff --git a/android-interop-testing/app/build.gradle b/android-interop-testing/app/build.gradle index 38339844ef..f0f95db87e 100644 --- a/android-interop-testing/app/build.gradle +++ b/android-interop-testing/app/build.gradle @@ -1,10 +1,6 @@ -apply plugin: 'android-sdk-manager' apply plugin: 'com.android.application' apply plugin: 'com.google.protobuf' -def properties = new Properties() -properties.load(new FileInputStream(file('../../version.properties'))) - android { compileSdkVersion 22 buildToolsVersion '22.0.1' @@ -37,7 +33,7 @@ protobuf { } plugins { grpc { - artifact = "io.grpc:protoc-gen-grpc-java:${properties.version}" + artifact = 'io.grpc:protoc-gen-grpc-java:0.9.0-SNAPSHOT' } } generateProtoTasks { @@ -68,9 +64,10 @@ dependencies { compile 'com.squareup.okhttp:okhttp:2.2.0' testCompile 'junit:junit:4.12' // You need to build grpc-java to obtain these libraries below. - compile "io.grpc:grpc-android:${properties.version}" - compile "io.grpc:grpc-protobuf-nano:${properties.version}" - compile "io.grpc:grpc-stub:${properties.version}" - compile "io.grpc:grpc-testing:${properties.version}" + compile 'io.grpc:grpc-core:0.9.0-SNAPSHOT' + compile 'io.grpc:grpc-protobuf-nano:0.9.0-SNAPSHOT' + compile 'io.grpc:grpc-okhttp:0.9.0-SNAPSHOT' + compile 'io.grpc:grpc-stub:0.9.0-SNAPSHOT' + compile 'io.grpc:grpc-testing:0.9.0-SNAPSHOT' compile 'javax.annotation:javax.annotation-api:1.2' -} \ No newline at end of file +} diff --git a/android-interop-testing/build.gradle b/android-interop-testing/build.gradle index fa0c670ac6..9b34fb97f7 100644 --- a/android-interop-testing/build.gradle +++ b/android-interop-testing/build.gradle @@ -5,7 +5,6 @@ buildscript { jcenter() } dependencies { - classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+' classpath 'com.android.tools.build:gradle:1.1.0' classpath "com.google.protobuf:protobuf-gradle-plugin:0.6.1" diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index ecc5f6bd60..0000000000 --- a/android/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -// We fork the android build to avoid classpath conflicts from buildscript. -task prereqs(dependsOn: [':grpc-okhttp:install', ':grpc-core:install']) {} - -task assemble(type: GradleBuild, dependsOn: 'prereqs') { - buildFile = 'delegate.gradle' - tasks = ['assemble'] -} - -task build(type: GradleBuild, dependsOn: 'prereqs') { - buildFile = 'delegate.gradle' - tasks = ['build'] -} - -task install(type: GradleBuild, dependsOn: 'prereqs') { - buildFile = 'delegate.gradle' - tasks = ['install'] -} - -task uploadArchives(type: GradleBuild, dependsOn: 'prereqs') { - buildFile = 'delegate.gradle' - tasks = ['uploadArchives'] -} - -task clean(type: GradleBuild) { - buildFile = 'delegate.gradle' - tasks = ['clean'] -} diff --git a/android/delegate.gradle b/android/delegate.gradle deleted file mode 100644 index d653e8a036..0000000000 --- a/android/delegate.gradle +++ /dev/null @@ -1,151 +0,0 @@ -buildscript { - repositories { - mavenCentral() - mavenLocal() - } - dependencies { - classpath 'com.android.tools.build:gradle:1.3.+' - classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+' - classpath 'com.github.dcendents:android-maven-plugin:1.2' - } -} -apply plugin: 'android-sdk-manager' -apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' -apply plugin: 'signing' - -def properties = new Properties() -properties.load(new FileInputStream(file('../version.properties'))) - -description = 'gRPC: Android' -group = "io.grpc" -version = "${properties.version}" - -repositories { - mavenCentral() - mavenLocal() -} - -// Need to override to ensure maven artifact is generated with correct name -// Must match uploadTask.repositories.mavenDeployer.pom.artifactId -project.archivesBaseName = "grpc-android" - -android { - // Matches preinstalled on travis to keep CI build times down - compileSdkVersion 21 - buildToolsVersion '21.1.1' - - defaultConfig { - minSdkVersion 9 - targetSdkVersion 21 - versionCode 1 - versionName "1.0" - } - lintOptions { - disable 'InvalidPackage', 'HardcodedText' - } -} - -// Disable JavaDoc doclint on Java 8. It's annoying. -if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } -} - -configurations { - javadocDeps -} - -dependencies { - compile "io.grpc:grpc-okhttp:${properties.version}" - javadocDeps "io.grpc:grpc-okhttp:${properties.version}" - - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.9.5' -} - -signing { - required false - sign configurations.archives -} - -uploadArchives.repositories.mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - String stagingUrl - if (rootProject.hasProperty('repositoryId')) { - stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + - rootProject.repositoryId - } else { - stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' - } - def configureAuth = { - if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { - authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword) - } - } - repository(url: stagingUrl, configureAuth) - snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) - pom.artifactId = 'grpc-android' -} - -[ - install.repositories.mavenInstaller, - uploadArchives.repositories.mavenDeployer, -]*.pom*.whenConfigured { pom -> - pom.project { - name "$project.group:grpc-android" - description project.description - packaging 'aar' - url 'https://github.com/grpc/grpc-java' - - scm { - connection 'scm:svn:https://github.com/grpc/grpc-java.git' - developerConnection 'scm:svn:git@github.com:grpc/grpc-java.git' - url 'https://github.com/grpc/grpc-java' - } - - licenses { - license { - name 'BSD 3-Clause' - url 'http://opensource.org/licenses/BSD-3-Clause' - } - } - - developers { - developer { - id "grpc.io" - name "gRPC Contributors" - email "grpc-io@googlegroups.com" - url "http://grpc.io/" - // https://issues.gradle.org/browse/GRADLE-2719 - organization = "Google, Inc." - organizationUrl "https://www.google.com" - } - } - } -} - -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - classpath += configurations.javadocDeps - destinationDir = file("../javadoc/") -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -artifacts { - archives javadocJar - archives sourcesJar -} diff --git a/android/src/androidTest/java/io/grpc/android/AndroidChannelBuilderTest.java b/android/src/androidTest/java/io/grpc/android/AndroidChannelBuilderTest.java deleted file mode 100644 index fa49e91bd9..0000000000 --- a/android/src/androidTest/java/io/grpc/android/AndroidChannelBuilderTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2014, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.grpc.android; - -import static org.junit.Assert.assertNotNull; - -import io.grpc.ManagedChannel; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * Tests for {@link io.grpc.android.AndroidChannelBuilder}. - */ -@RunWith(JUnit4.class) -public class AndroidChannelBuilderTest { - - @Test - public void testDefaultProducesChannel() { - AndroidChannelBuilder channelBuilder = AndroidChannelBuilder.forAddress("localhost", 1234); - channelBuilder.userAgent("test"); - ManagedChannel channel = channelBuilder.build(); - assertNotNull(channel); - channel.shutdownNow(); - } -} diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml deleted file mode 100644 index e41a7da94b..0000000000 --- a/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - diff --git a/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java b/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java deleted file mode 100644 index 5baa6c2cd4..0000000000 --- a/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2014, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.grpc.android; - -import io.grpc.ClientInterceptor; -import io.grpc.ExperimentalApi; -import io.grpc.ManagedChannelBuilder; -import io.grpc.internal.ManagedChannelImpl; -import io.grpc.okhttp.NegotiationType; -import io.grpc.okhttp.OkHttpChannelBuilder; - -import java.util.List; -import java.util.concurrent.Executor; - -/** - * A {@link io.grpc.ManagedChannelBuilder} that provides a stable interface for producing - * {@link io.grpc.Channel} instances on Android. This allows applications to be resilient - * to changes such as defaulting to a new channel implementation or breaking API changes - * in existing ones. Configuration options will be added here only if they provide value - * to a broad set of users and are likely to be resilient to changes in the underlying channel - * implementation. - * - *

Developers needing advanced configuration are free to use the underlying channel - * implementations directly while assuming the risks associated with using an - * {@link io.grpc.ExperimentalApi}. - */ - -// TODO(lryan): -// - Document the various dangers of scheduling work onto Android Main/UI/whatever -// threads. Is any enforcement practical? Conversely is there a sensible default. I assume -// its also a bad idea to use huge numbers of threads too. -// - Provide SSL installation and detect ALPN/NPN support? -// - Allow for an alternate TrustManager ? for self-signed, pinning etc. Is there a good default -// impl for these variations blessed by security team? -// - Augment with user-agent with app id? -// - Specify a smaller flow-control window by default? Fewer concurrent streams? -public class AndroidChannelBuilder extends ManagedChannelBuilder { - // Currently we only support OkHttp on Android. This will become dynamic as more transport - // implementations become available. - private final OkHttpChannelBuilder baseBuilder; - - public static AndroidChannelBuilder forAddress(String host, int port) { - return new AndroidChannelBuilder(OkHttpChannelBuilder.forAddress(host, port)); - } - - private AndroidChannelBuilder(OkHttpChannelBuilder builder) { - this.baseBuilder = builder; - } - - @Override - public AndroidChannelBuilder executor(Executor executor) { - baseBuilder.executor(executor); - return this; - } - - @Override - public AndroidChannelBuilder intercept(List list) { - baseBuilder.intercept(list); - return this; - } - - @Override - public AndroidChannelBuilder intercept(ClientInterceptor... interceptors) { - baseBuilder.intercept(interceptors); - return this; - } - - @Override - public AndroidChannelBuilder userAgent(String userAgent) { - baseBuilder.userAgent(userAgent); - return this; - } - - /** - * Use of a plaintext connection to the server. By default a secure connection mechanism - * such as TLS will be used. - * - *

Should only be used for testing or for APIs where the use of such API or the data - * exchanged is not sensitive. - * - * @param skipNegotiation @{code true} if there is a priori knowledge that the endpoint supports - * plaintext, {@code false} if plaintext use must be negotiated. - */ - @ExperimentalApi("primarily for testing") - public AndroidChannelBuilder usePlaintext(boolean skipNegotiation) { - if (skipNegotiation) { - baseBuilder.negotiationType(NegotiationType.PLAINTEXT); - return this; - } else { - throw new IllegalArgumentException("Not currently supported"); - } - } - - /** - * Overrides the host used with TLS and HTTP virtual hosting. It does not change what host is - * actually connected to. - * - *

Should only be used for testing. - */ - @ExperimentalApi("primarily for testing") - public AndroidChannelBuilder overrideHostForAuthority(String host) { - baseBuilder.overrideHostForAuthority(host); - return this; - } - - @Override - public ManagedChannelImpl build() { - return baseBuilder.build(); - } -} diff --git a/build.gradle b/build.gradle index 1ecfc0f916..fd97364025 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } } -configure(subprojects - project(":grpc-android")) { +subprojects { apply plugin: "checkstyle" apply plugin: "java" apply plugin: "maven" @@ -17,11 +17,8 @@ configure(subprojects - project(":grpc-android")) { apply plugin: "signing" apply plugin: "jacoco" - def properties = new Properties() - properties.load(new FileInputStream("version.properties")) - group = "io.grpc" - version = properties.version + version = "0.9.0-SNAPSHOT" sourceCompatibility = 1.6 targetCompatibility = 1.6 diff --git a/settings.gradle b/settings.gradle index f746b975c2..27d128e4a9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,7 +11,6 @@ include ":grpc-interop-testing" include ":grpc-all" include ":grpc-benchmarks" include ":grpc-examples" -include ":grpc-android" project(':grpc-core').projectDir = "$rootDir/core" as File project(':grpc-stub').projectDir = "$rootDir/stub" as File @@ -25,7 +24,6 @@ project(':grpc-interop-testing').projectDir = "$rootDir/interop-testing" as File project(':grpc-all').projectDir = "$rootDir/all" as File project(':grpc-benchmarks').projectDir = "$rootDir/benchmarks" as File project(':grpc-examples').projectDir = "$rootDir/examples" as File -project(':grpc-android').projectDir = "$rootDir/android" as File if (settings.hasProperty('skipCodegen') && skipCodegen.toBoolean()) { println '*** Skipping the build of codegen and compilation of proto files because skipCodegen=true' diff --git a/version.properties b/version.properties deleted file mode 100644 index 45af0a82f3..0000000000 --- a/version.properties +++ /dev/null @@ -1 +0,0 @@ -version = 0.9.0-SNAPSHOT