diff --git a/.editorconfig b/.editorconfig index 0fdd49060..d107cd585 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,7 +9,7 @@ charset = utf-8 indent_style = space indent_size = 2 -[*.{java,groovy,gradle}] +[*.{java,groovy,gradle,kts}] indent_size = 4 [*.md] diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 4f4e9376d..98508cf54 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -12,4 +12,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - run: ./gradlew checkstyleMain checkstyleTest checkWithCodenarc runUnitTests + - name: Set up the JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - run: ./gradlew checkWithCodenarc checkstyleMain checkstyleTest runUnitTests diff --git a/.github/workflows/emulate.yml b/.github/workflows/emulate.yml index 64eda9500..10a3ad2d5 100644 --- a/.github/workflows/emulate.yml +++ b/.github/workflows/emulate.yml @@ -18,6 +18,12 @@ jobs: - name: checkout uses: actions/checkout@v4 + - name: Set up the JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Enable KVM run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 08a3b459f..64db71862 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -15,6 +15,12 @@ jobs: with: submodules: 'recursive' + - name: Set up the JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - run: ./gradlew :java:testRestSuite - uses: actions/upload-artifact@v3 @@ -30,6 +36,12 @@ jobs: with: submodules: 'recursive' + - name: Set up the JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - run: ./gradlew :java:testRealtimeSuite - uses: actions/upload-artifact@v3 diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index fff44a37b..6c5ccdcbc 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -25,8 +25,8 @@ jobs: - name: Set up the JDK uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'adopt' + java-version: '17' + distribution: 'temurin' - name: Build docs run: ./gradlew javadoc diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b98399897..7bf2ca18c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -201,8 +201,7 @@ implementation files('libs/ably-android-1.2.42.aar') This library uses [semantic versioning](http://semver.org/). For each release, the following needs to be done: 1. Create a branch for the release, named like `release/1.2.4` (where `1.2.4` is what you're releasing, being the new version) -2. Replace all references of the current version number with the new version number (check the [README.md](./README.md) and [common.gradle](./common.gradle)) and commit the changes - a. Increment the `versionCode` in the Android project's `build.gradle` by 1 +2. Replace all references of the current version number with the new version number (check the [README.md](./README.md) and [gradle.properties](./gradle.properties)) and commit the changes 3. Run [`github_changelog_generator`](https://github.com/github-changelog-generator/github-changelog-generator) to automate the update of the [CHANGELOG](./CHANGELOG.md). This may require some manual intervention, both in terms of how the command is run and how the change log file is modified. Your mileage may vary: - The command you will need to run will look something like this: `github_changelog_generator -u ably -p ably-java --since-tag v1.2.3 --output delta.md --token $GITHUB_TOKEN_WITH_REPO_ACCESS`. Generate token [here](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token). - Using the command above, `--output delta.md` writes changes made after `--since-tag` to a new file. @@ -212,12 +211,10 @@ This library uses [semantic versioning](http://semver.org/). For each release, t 5. Make a PR against `main` 6. Once the PR is approved, merge it into `main` 7. From the updated `main` branch on your local workstation, assemble and upload: - 1. Run `./gradlew java:assembleRelease -PpublishTarget=MavenCentral` to build and upload `ably-java` to Nexus staging repository - 2. Run `./gradlew android:assembleRelease -PpublishTarget=MavenCentral` build and upload `ably-android` to Nexus staging repository - 3. Find the new staging repository using the [Nexus Repository Manager](https://oss.sonatype.org/#stagingRepositories) - 4. Check that it contains `ably-android` and `ably-java` releases - 5. "Close" it - this will take a few minutes during which time it will say (after a refresh of your browser) that "Activity: Operation in Progress" - 6. Once it has closed you will have "Release" available. You can allow it to "automatically drop" after successful release. A refresh or two later of the browser and the staging repository will have disappeared from the list (i.e. it's been dropped which implies it was released successfully) + 1. Run `./gradlew publishToMavenCentral` to build and upload `ably-java` and `ably-android` to Nexus staging repository + 2. Find the new staging repository using the [Nexus Repository Manager](https://oss.sonatype.org/#stagingRepositories) + 3. Check that it contains `ably-android` and `ably-java` releases + 4. "Release" it - this will take a few minutes during which time it will say (after a refresh of your browser) that "Activity: Operation in Progress". You can allow it to "automatically drop" after successful release. A refresh or two later of the browser and the staging repository will have disappeared from the list (i.e. it's been dropped which implies it was released successfully) 7. A [search for Ably packages](https://oss.sonatype.org/#nexus-search;quick~io.ably) should now list the new version for both `ably-android` and `ably-java` 8. Add a tag and push to origin - e.g.: `git tag v1.2.4 && git push origin v1.2.4` 9. Create the release on Github including populating the release notes diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index c422c3373..000000000 --- a/android/build.gradle +++ /dev/null @@ -1,105 +0,0 @@ -buildscript { - repositories { - mavenCentral() - mavenLocal() - google() - } - dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' - } -} - -apply plugin: 'com.android.library' -apply from: '../common.gradle' - -ext { - artifactId = 'ably-android' -} - -allprojects { - repositories { - google() - } -} - -android { - compileSdkVersion 30 - - defaultConfig { - buildConfigField 'String', 'LIBRARY_NAME', '"android"' - buildConfigField 'String', 'VERSION', "\"$version\"" - minSdkVersion 19 - targetSdkVersion 30 - // This MUST be incremented by 1 on each ably-java release - versionCode 17 - versionName version - setProperty('archivesBaseName', "ably-android-$versionName") - testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' - testInstrumentationRunnerArgument 'class', 'io.ably.lib.test.android.AndroidPushTest' - //testInstrumentationRunnerArgument "class", "io.ably.lib.test.rest.RestSuite,io.ably.lib.test.realtime.RealtimeSuite,io.ably.lib.test.android.AndroidSuite,io.ably.lib.test.android.AndroidPushTest" - testInstrumentationRunnerArgument 'timeout_msec', '300000' -// testInstrumentationRunnerArgument "ABLY_ENV", "\"$System.env.ABLY_ENV\"" - consumerProguardFiles 'proguard.txt' - } - - compileOptions { - sourceCompatibility 1.8 - targetCompatibility 1.8 - } - - buildTypes { - release { - minifyEnabled false - } - } - - lintOptions { - abortOnError false - } - - sourceSets { - main { - java { - srcDirs = ['src/main/java', '../lib/src/main/java'] - } - } - androidTest { - java { - srcDirs = ['src/androidTest/java', '../lib/src/test/java'] - } - assets { - srcDirs = ['../lib/src/test/resources'] - } - } - } -} - -/* Fix for android test logging. Source: https://code.google.com/p/android/issues/detail?id=182307 */ -tasks.withType(com.android.build.gradle.internal.tasks.AndroidTestTask) { task -> - task.doFirst { - logging.level = LogLevel.INFO - } - task.doLast { - logging.level = LogLevel.LIFECYCLE - } -} - -apply from: '../dependencies.gradle' -dependencies { - implementation 'com.google.firebase:firebase-messaging:22.0.0' - androidTestImplementation 'com.android.support.test:runner:0.5' - androidTestImplementation 'com.android.support.test:rules:0.5' - androidTestImplementation 'com.crittercism.dexmaker:dexmaker:1.4' - androidTestImplementation 'com.crittercism.dexmaker:dexmaker-dx:1.4' - androidTestImplementation 'com.crittercism.dexmaker:dexmaker-mockito:1.4' - androidTestImplementation 'net.sourceforge.streamsupport:android-retrostreams:1.7.4' -} - -configurations { - all*.exclude group: 'org.hamcrest', module: 'hamcrest-core' - androidTestImplementation { - extendsFrom testImplementation - } -} - -apply from: 'maven.gradle' diff --git a/android/build.gradle.kts b/android/build.gradle.kts new file mode 100644 index 000000000..c66a5ee66 --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,66 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.maven.publish) +} + +android { + namespace = "io.ably.lib" + defaultConfig { + minSdk = 19 + compileSdk = 30 + buildConfigField("String", "LIBRARY_NAME", "\"android\"") + buildConfigField("String", "VERSION", "\"${property("VERSION_NAME")}\"") + testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunnerArguments["class"] = "io.ably.lib.test.android.AndroidPushTest" + testInstrumentationRunnerArguments["timeout_msec"] = "300000" + consumerProguardFiles("proguard.txt") + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + } + } + + buildFeatures { + buildConfig = true + } + + lint { + abortOnError = false + } + + testOptions.targetSdk = 30 + + sourceSets { + getByName("main") { + java.srcDirs("src/main/java", "../lib/src/main/java") + } + getByName("androidTest") { + java.srcDirs("src/androidTest/java", "../lib/src/test/java") + assets.srcDirs("../lib/src/test/resources") + } + } +} + +dependencies { + api(libs.gson) + implementation(libs.bundles.common) + testImplementation(libs.bundles.tests) + implementation(libs.firebase.messaging) + androidTestImplementation(libs.bundles.instrumental.android) +} + +configurations { + all { + exclude(group = "org.hamcrest", module = "hamcrest-core") + } + getByName("androidTestImplementation") { + extendsFrom(configurations.getByName("testImplementation")) + } +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 000000000..c08c36bea --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,4 @@ +POM_ARTIFACT_ID=ably-android +POM_NAME=Ably Android client library SDK +POM_DESCRIPTION=An Android Realtime and REST client library SDK for the Ably platform. +POM_PACKAGING=aar diff --git a/android/maven.gradle b/android/maven.gradle deleted file mode 100644 index 88e1ec7ae..000000000 --- a/android/maven.gradle +++ /dev/null @@ -1,149 +0,0 @@ -apply plugin: 'maven' -apply plugin: 'signing' - -final String GROUP_ID = 'io.ably' -final String ARTIFACT_ID = 'ably-android' -final String LOCAL_RELEASE_DESTINATION = "${buildDir}/release/${version}" -final String MAVEN_USER = findProperty('ossrhUsername') -final String MAVEN_PASSWORD = findProperty('ossrhPassword') - -final boolean IS_PUBLISHING_TO_MAVEN_CENTRAL = findProperty('publishTarget') == 'MavenCentral' -if (IS_PUBLISHING_TO_MAVEN_CENTRAL && (MAVEN_USER == null || MAVEN_PASSWORD == null)) { - throw new GradleException('Either ossrhUsername or ossrhPassword not specified when publishTarget is MavenCentral.') -} - -/* - * Task which signs and uploads the Android artifacts to Nexus OSSRH. - */ -uploadArchives { - signing { - sign configurations.archives - } - repositories.mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - pom.groupId = GROUP_ID - pom.artifactId = ARTIFACT_ID - pom.version = version - - pom.project { - name 'Ably Android client library SDK' - description 'An Android Realtime and REST client library SDK for the Ably platform.' - packaging 'aar' - inceptionYear '2015' - url 'https://www.github.com/ably/ably-java' - developers { - developer { - id 'ably' // our company org in GitHub: https://github.com/ably - name 'Ably' // UK based company: Ably Real-time Ltd - email 'support@ably.com' - url 'https://ably.com/' - } - } - scm { - url 'https://github.com/ably/ably-java' - connection 'scm:git:git://github.com/ably/ably-java.git' - developerConnection 'scm:git:ssh://github.com/ably/ably-java.git' - tag = 'v' + version - } - organization { - name 'Ably' // UK based company: Ably Real-time Ltd - url 'https://ably.com/' - } - issueManagement { - system 'Github' - url 'https://github.com/ably/ably-java/issues' - } - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'https://raw.github.com/ably/ably-java/main/LICENSE' - distribution 'repo' - } - } - } - - pom.whenConfigured { p -> - p.dependencies = p.dependencies.findAll { - // Exclude dependency on lib subproject. - dep -> dep.artifactId != 'lib' - }.findAll { - // Exclude Google services since we don't want to impose a particular - // version on users. Ideally we would specify a version range, - // but the Google services Gradle plugin doesn't seem to - // support that. - // TODO: Make sure this works when installing from Maven! - dep -> dep.artifactId != 'play-services-gcm' && dep.artifactId != 'firebase-messaging' - } - } - - if (IS_PUBLISHING_TO_MAVEN_CENTRAL) { - repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') { - authentication(userName: MAVEN_USER, password: MAVEN_PASSWORD) - } - - snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') { - authentication(userName: MAVEN_USER, password: MAVEN_PASSWORD) - } - } else { - // Export to local Maven cache - repository(url: repositories.mavenLocal().url) - - // Export files to local storage - repository(url: "file://${LOCAL_RELEASE_DESTINATION}") - } - } -} - -task zipRelease(type: Zip) { - from LOCAL_RELEASE_DESTINATION - destinationDir buildDir - archiveName "release-${version}.zip" -} - -tasks.whenTaskAdded { task -> - if (task.name == 'assembleRelease') { - task.doLast { - if (IS_PUBLISHING_TO_MAVEN_CENTRAL) { - logger.quiet('✅ Release uploaded to Sonatype Staging Repository') - } else { - logger.quiet("✅ Release ${version} can be found at ${LOCAL_RELEASE_DESTINATION}/") - logger.quiet("✅ Release ${version} zipped can be found ${buildDir}/release-${version}.zip") - } - } - - task.dependsOn(uploadArchives) - task.dependsOn(zipRelease) - } -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.srcDirs -} - -task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.bootClasspath.join(File.pathSeparator)) - failOnError false - title = 'Ably documentation' - options.overview = '../overview.html' -} - -afterEvaluate { - javadoc.classpath += files(android.libraryVariants.collect { variant -> - variant.javaCompile.classpath.files - }) -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - javadoc.title = 'Ably documentation' - javadoc.options.overview = '../overview.html' -} - -artifacts { - archives sourcesJar - archives javadocJar -} diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index c904374e2..6fc6facb7 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,7 +1,4 @@ - - + - diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 8cf9d7745..000000000 --- a/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -plugins { - id 'io.codearte.nexus-staging' version '0.21.1' -} - -repositories { - google() - mavenCentral() -} - -nexusStaging { - packageGroup = 'io.ably' -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..d031f19d9 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,35 @@ +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.SonatypeHost + +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +plugins { + alias(libs.plugins.android.library) apply false + alias(libs.plugins.maven.publish) apply false +} + +subprojects { + repositories { + google() + mavenCentral() + } + + tasks.withType { + // To prevent javadoc warnings with Java 8 + options { + this as StandardJavadocDocletOptions + addBooleanOption("Xdoclint:none", true) + addBooleanOption("quiet", true) + addStringOption("Xmaxwarns", "1") + } + } +} + +configure(subprojects) { + pluginManager.withPlugin("com.vanniktech.maven.publish") { + extensions.configure { + publishToMavenCentral(SonatypeHost.DEFAULT) + signAllPublications() + } + } +} diff --git a/common.gradle b/common.gradle deleted file mode 100644 index 7d98567bd..000000000 --- a/common.gradle +++ /dev/null @@ -1,12 +0,0 @@ -repositories { - mavenCentral() -} - -group = 'io.ably' -version = '1.2.42' -description = 'Ably java client library' - -tasks.withType(Javadoc) { - // To prevent javadoc warnings with Java 8 - options.addStringOption('Xdoclint:none', '-quiet') -} diff --git a/dependencies.gradle b/dependencies.gradle deleted file mode 100644 index 6d1b9ea12..000000000 --- a/dependencies.gradle +++ /dev/null @@ -1,16 +0,0 @@ -// These dependencies have to be in lib/build.gradle for compilation _and_ -// in java/build.gradle and android/build.gradle for maven. -dependencies { - implementation 'org.msgpack:msgpack-core:0.8.11' - implementation 'org.java-websocket:Java-WebSocket:1.5.3' - implementation 'com.google.code.gson:gson:2.9.0' - implementation 'com.davidehrmann.vcdiff:vcdiff-core:0.1.1' - testImplementation 'org.hamcrest:hamcrest-all:1.3' - testImplementation 'junit:junit:4.12' - testImplementation 'org.nanohttpd:nanohttpd:2.3.0' - testImplementation 'org.nanohttpd:nanohttpd-nanolets:2.3.0' - testImplementation 'org.nanohttpd:nanohttpd-websocket:2.3.0' - testImplementation 'org.mockito:mockito-core:1.10.19' - testImplementation 'net.jodah:concurrentunit:0.4.2' - testImplementation 'org.slf4j:slf4j-simple:1.7.30' -} diff --git a/gradle.properties b/gradle.properties index d9cf55df7..b24da7ddf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,20 @@ +GROUP=io.ably +VERSION_NAME=1.2.42 + +POM_INCEPTION_YEAR=2015 +POM_URL=https://github.com/ably/ably-java +POM_SCM_URL=https://github.com/ably/ably-java/ +POM_SCM_CONNECTION=scm:git:git://github.com/ably/ably-java.git +POM_SCM_DEV_CONNECTION=scm:git:git@github.com:ably/ably-java.git + +POM_LICENSE_NAME=The Apache Software License, Version 2.0 +POM_LICENSE_URL=https://raw.github.com/ably/ably-java/main/LICENSE +POM_LICENSE_DIST=repo + +POM_DEVELOPER_ID=ably +POM_DEVELOPER_NAME=Ably +POM_DEVELOPER_URL=https://github.com/ably/ +SONATYPE_STAGING_PROFILE=io.ably + org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..241d7195c --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,49 @@ +[versions] +agp = "8.5.2" +junit = "4.12" +gson = "2.9.0" +msgpack = "0.8.11" +java-websocket = "1.5.3" +vcdiff = "0.1.1" +hamcrest = "1.3" +nanohttpd = "2.3.0" +mockito = "1.10.19" +concurrentunit = "0.4.2" +slf4j = "1.7.30" +build-config = "5.4.0" +firebase-messaging = "22.0.0" +android-test = "0.5" +dexmaker = "1.4" +android-retrostreams = "1.7.4" +maven-publish = "0.29.0" + +[libraries] +gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" } +msgpack = { group = "org.msgpack", name = "msgpack-core", version.ref = "msgpack" } +java-websocket = { group = "org.java-websocket", name = "Java-WebSocket", version.ref = "java-websocket" } +vcdiff-core = { group = "com.davidehrmann.vcdiff", name = "vcdiff-core", version.ref = "vcdiff" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +hamcrest-all = { group = "org.hamcrest", name = "hamcrest-all", version.ref = "hamcrest" } +nanohttpd = { group = "org.nanohttpd", name = "nanohttpd", version.ref = "nanohttpd" } +nanohttpd-nanolets = { group = "org.nanohttpd", name = "nanohttpd-nanolets", version.ref = "nanohttpd" } +nanohttpd-websocket = { group = "org.nanohttpd", name = "nanohttpd-websocket", version.ref = "nanohttpd" } +mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" } +concurrentunit = { group = "net.jodah", name = "concurrentunit", version.ref = "concurrentunit" } +slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version.ref = "slf4j" } +firebase-messaging = { group = "com.google.firebase", name = "firebase-messaging", version.ref = "firebase-messaging" } +android-test-runner = { group = "com.android.support.test", name = "runner", version.ref = "android-test" } +android-test-rules = { group = "com.android.support.test", name = "rules", version.ref = "android-test" } +dexmaker = { group = "com.crittercism.dexmaker", name = "dexmaker", version.ref = "dexmaker" } +dexmaker-dx = { group = "com.crittercism.dexmaker", name = "dexmaker-dx", version.ref = "dexmaker" } +dexmaker-mockito = { group = "com.crittercism.dexmaker", name = "dexmaker-mockito", version.ref = "dexmaker" } +android-retrostreams = { group = "net.sourceforge.streamsupport", name = "android-retrostreams", version.ref = "android-retrostreams" } + +[bundles] +common = ["msgpack", "java-websocket", "vcdiff-core"] +tests = ["junit","hamcrest-all", "nanohttpd", "nanohttpd-nanolets", "nanohttpd-websocket", "mockito-core", "concurrentunit", "slf4j-simple"] +instrumental-android = ["android-test-runner", "android-test-rules", "dexmaker", "dexmaker-dx", "dexmaker-mockito", "android-retrostreams"] + +[plugins] +android-library = { id = "com.android.library", version.ref = "agp" } +build-config = { id = "com.github.gmazzo.buildconfig", version.ref = "build-config" } +maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 87b738cbd..e708b1c02 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 33682bbbf..0ebc4df25 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Tue Sep 24 14:50:52 BST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index af6708ff2..4f906e0c8 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or 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 +# +# https://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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -66,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 0f8d5937c..ac1b06f93 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/java/build.gradle b/java/build.gradle deleted file mode 100644 index a4637f926..000000000 --- a/java/build.gradle +++ /dev/null @@ -1,113 +0,0 @@ -plugins { - id 'de.fuerstenau.buildconfig' version '1.1.8' - id 'checkstyle' -} - -apply plugin: 'java' -apply plugin: 'idea' -apply from: '../common.gradle' -apply from: 'maven.gradle' - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -apply from: '../dependencies.gradle' - -buildConfig { - packageName 'io.ably.lib' - clsName 'BuildConfig' - buildConfigField 'String', 'LIBRARY_NAME', 'java' -} - -sourceSets { - main { - java { - srcDirs = ['src/main/java', '../lib/src/main/java'] - } - } - test { - java { - srcDirs = ['src/test/java', '../lib/src/test/java'] - } - } -} - -// Default jar: add io.ably classes from :lib dependency. -jar { - baseName = 'ably-java' - from { - configurations.compile.collect { file -> - file.directory ? file : zipTree(file) - } - } - includes = ['**/io/ably/**'] - includeEmptyDirs false - exclude 'META-INF/**' -} - -// fullJar: add all classes from dependencies transitively. -task fullJar(type: Jar) { - baseName = 'ably-java' - classifier = 'full' - from { - configurations.compile.collect { file -> - file.directory ? file : zipTree(file) - } - } - with jar - exclude 'META-INF/**' -} - -assemble.dependsOn fullJar -assembleRelease.dependsOn checkstyleMain - -configurations { - fullConfiguration - testsConfiguration -} - -artifacts { - fullConfiguration fullJar -} - -task testRealtimeSuite(type: Test) { - filter { - includeTestsMatching '*RealtimeSuite' - } - beforeTest { descriptor -> - logger.lifecycle("-> $descriptor") - } - outputs.upToDateWhen { false } - testLogging.exceptionFormat = 'full' -} - -task testRestSuite(type: Test) { - filter { - includeTestsMatching '*RestSuite' - } - beforeTest { descriptor -> - logger.lifecycle("-> $descriptor") - } - outputs.upToDateWhen { false } - testLogging.exceptionFormat = 'full' -} - -/* -Test task to run pure unit tests, where pure means that they only run -locally and do not need to communicate with Ably servers. -This is achieved by excluding everything in the io.ably.lib.test package, -as it only contains the REST and Realtime suites. -*/ -task runUnitTests(type: Test) { - filter { - excludeTestsMatching 'io.ably.lib.test.*' - } - beforeTest { descriptor -> - // informational, so we're not flying blind at runtime - logger.lifecycle("-> $descriptor") - } - - // force tests to run every time this task is invoked - outputs.upToDateWhen { false } -} - diff --git a/java/build.gradle.kts b/java/build.gradle.kts new file mode 100644 index 000000000..21c3f87af --- /dev/null +++ b/java/build.gradle.kts @@ -0,0 +1,89 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat + +plugins { + alias(libs.plugins.build.config) + alias(libs.plugins.maven.publish) + checkstyle + `java-library` +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +tasks.withType { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} + +dependencies { + api(libs.gson) + implementation(libs.bundles.common) + testImplementation(libs.bundles.tests) +} + +buildConfig { + useJavaOutput() + packageName = "io.ably.lib" + buildConfigField("String", "LIBRARY_NAME", "\"java\"") + buildConfigField("String", "VERSION", "\"${property("VERSION_NAME")}\"") +} + +sourceSets { + named("main") { + java { + srcDirs("src/main/java", "../lib/src/main/java") + } + } + named("test") { + java { + srcDirs("src/test/java", "../lib/src/test/java") + } + } +} + +tasks.checkstyleMain.configure { + exclude("io/ably/lib/BuildConfig.java") +} + +tasks.register("testRealtimeSuite") { + filter { + includeTestsMatching("*RealtimeSuite") + } + jvmArgs("--add-opens", "java.base/java.time=ALL-UNNAMED") + jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED") + beforeTest(closureOf { logger.lifecycle("-> $this") }) + outputs.upToDateWhen { false } + testLogging { + exceptionFormat = TestExceptionFormat.FULL + } +} + +tasks.register("testRestSuite") { + filter { + includeTestsMatching("*RestSuite") + } + jvmArgs("--add-opens", "java.base/java.time=ALL-UNNAMED") + jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED") + beforeTest(closureOf { logger.lifecycle("-> $this") }) + outputs.upToDateWhen { false } + testLogging { + exceptionFormat = TestExceptionFormat.FULL + } +} + +/* +Test task to run pure unit tests, where pure means that they only run +locally and do not need to communicate with Ably servers. +This is achieved by excluding everything in the io.ably.lib.test package, +as it only contains the REST and Realtime suites. +*/ +tasks.register("runUnitTests") { + filter { + excludeTestsMatching("io.ably.lib.test.*") + } + jvmArgs("--add-opens", "java.base/java.time=ALL-UNNAMED") + jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED") + beforeTest(closureOf { logger.lifecycle("-> $this") }) + outputs.upToDateWhen { false } +} diff --git a/java/gradle.properties b/java/gradle.properties new file mode 100644 index 000000000..bff480295 --- /dev/null +++ b/java/gradle.properties @@ -0,0 +1,4 @@ +POM_ARTIFACT_ID=ably-java +POM_NAME=Ably Java client library SDK +POM_DESCRIPTION=A Java Realtime and REST client library SDK for the Ably platform. +POM_PACKAGING=jar diff --git a/java/maven.gradle b/java/maven.gradle deleted file mode 100644 index 0679702d7..000000000 --- a/java/maven.gradle +++ /dev/null @@ -1,123 +0,0 @@ -apply plugin: 'java' -apply plugin: 'maven' -apply plugin: 'signing' - -final String GROUP_ID = 'io.ably' -final String ARTIFACT_ID = 'ably-java' -final String LOCAL_RELEASE_DESTINATION = "${buildDir}/release/${version}" -final String MAVEN_USER = findProperty('ossrhUsername') -final String MAVEN_PASSWORD = findProperty('ossrhPassword') - -final boolean IS_PUBLISHING_TO_MAVEN_CENTRAL = findProperty('publishTarget') == 'MavenCentral' -if (IS_PUBLISHING_TO_MAVEN_CENTRAL && (MAVEN_USER == null || MAVEN_PASSWORD == null)) { - throw new GradleException('Either ossrhUsername or ossrhPassword not specified when publishTarget is MavenCentral.') -} - -/* - * Task which signs and uploads the Java artifacts to Nexus OSSRH. - */ -uploadArchives { - signing { - sign configurations.archives - } - repositories.mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - pom.groupId = GROUP_ID - pom.artifactId = ARTIFACT_ID - pom.version = version - - pom.project { - name 'Ably Java client library SDK' - description 'A Java Realtime and REST client library SDK for the Ably platform.' - packaging 'jar' - inceptionYear '2015' - url 'https://www.github.com/ably/ably-java' - developers { - developer { - id 'ably' // our company org in GitHub: https://github.com/ably - name 'Ably' // UK based company: Ably Real-time Ltd - email 'support@ably.com' - url 'https://ably.com/' - } - } - scm { - url 'https://github.com/ably/ably-java' - connection 'scm:git:git://github.com/ably/ably-java.git' - developerConnection 'scm:git:ssh://github.com/ably/ably-java.git' - tag = 'v' + version - } - organization { - name 'Ably' // UK based company: Ably Real-time Ltd - url 'https://ably.com/' - } - issueManagement { - system 'Github' - url 'https://github.com/ably/ably-java/issues' - } - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'https://raw.github.com/ably/ably-java/main/LICENSE' - distribution 'repo' - } - } - } - - // Exclude test dependencies - pom.whenConfigured { p -> - p.dependencies = p.dependencies.findAll { - dep -> dep.scope == 'runtime' - } - } - - if (IS_PUBLISHING_TO_MAVEN_CENTRAL) { - repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') { - authentication(userName: MAVEN_USER, password: MAVEN_PASSWORD) - } - - snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') { - authentication(userName: MAVEN_USER, password: MAVEN_PASSWORD) - } - } else { - // Export files to local storage - repository(url: "file://${LOCAL_RELEASE_DESTINATION}") - } - } -} - -task zipRelease(type: Zip) { - from LOCAL_RELEASE_DESTINATION - destinationDir buildDir - archiveName "release-${version}.zip" -} - -task assembleRelease { - doLast { - if (IS_PUBLISHING_TO_MAVEN_CENTRAL) { - logger.quiet('✅ Release uploaded to Sonatype Staging Repository') - } else { - logger.quiet("✅ Release ${version} can be found at ${LOCAL_RELEASE_DESTINATION}") - logger.quiet("✅ Release ${version} zipped can be found ${buildDir}/release-${version}.zip") - } - } - dependsOn(uploadArchives) - dependsOn(zipRelease) -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - javadoc.title = 'Ably documentation' - javadoc.options.overview = '../overview.html' -} - -artifacts { - archives sourcesJar - archives javadocJar -} diff --git a/lib/src/main/java/io/ably/lib/http/HttpCore.java b/lib/src/main/java/io/ably/lib/http/HttpCore.java index e224262c6..7b3bb64bb 100644 --- a/lib/src/main/java/io/ably/lib/http/HttpCore.java +++ b/lib/src/main/java/io/ably/lib/http/HttpCore.java @@ -1,21 +1,6 @@ package io.ably.lib.http; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.lang.reflect.Field; -import java.net.HttpURLConnection; -import java.net.InetSocketAddress; -import java.net.Proxy; -import java.net.URL; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - import com.google.gson.JsonParseException; - import io.ably.lib.debug.DebugOptions; import io.ably.lib.debug.DebugOptions.RawHttpListener; import io.ably.lib.rest.Auth; @@ -32,11 +17,56 @@ import io.ably.lib.util.Log; import io.ably.lib.util.PlatformAgentProvider; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.net.HttpURLConnection; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.URL; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + /** * HttpCore performs authenticated HTTP synchronously. Internal; use Http or HttpScheduler instead. */ public class HttpCore { + private static final String TAG = HttpCore.class.getName(); + + /************************* + * Private state + *************************/ + + static { + /* if on Android, check version */ + Field androidVersionField = null; + int androidVersion = 0; + try { + androidVersionField = Class.forName("android.os.Build$VERSION").getField("SDK_INT"); + androidVersion = androidVersionField.getInt(androidVersionField); + } catch (Exception e) { + } + if (androidVersionField != null && androidVersion < 8) { + /* HTTP connection reuse which was buggy pre-froyo */ + System.setProperty("httpCore.keepAlive", "false"); + } + } + + public final String scheme; + public final int port; + final ClientOptions options; + final Hosts hosts; + private final Auth auth; + private final ProxyOptions proxyOptions; + private final PlatformAgentProvider platformAgentProvider; + private HttpAuth proxyAuth; + private Proxy proxy = Proxy.NO_PROXY; + /************************* * Public API *************************/ @@ -50,16 +80,22 @@ public HttpCore(ClientOptions options, Auth auth, PlatformAgentProvider platform this.hosts = new Hosts(options.restHost, Defaults.HOST_REST, options); this.proxyOptions = options.proxy; - if(proxyOptions != null) { + if (proxyOptions != null) { String proxyHost = proxyOptions.host; - if(proxyHost == null) { throw AblyException.fromErrorInfo(new ErrorInfo("Unable to configure proxy without proxy host", 40000, 400)); } + if (proxyHost == null) { + throw AblyException.fromErrorInfo(new ErrorInfo("Unable to configure proxy without proxy host", 40000, 400)); + } int proxyPort = proxyOptions.port; - if(proxyPort == 0) { throw AblyException.fromErrorInfo(new ErrorInfo("Unable to configure proxy without proxy port", 40000, 400)); } + if (proxyPort == 0) { + throw AblyException.fromErrorInfo(new ErrorInfo("Unable to configure proxy without proxy port", 40000, 400)); + } this.proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)); String proxyUser = proxyOptions.username; - if(proxyUser != null) { + if (proxyUser != null) { String proxyPassword = proxyOptions.password; - if(proxyPassword == null) { throw AblyException.fromErrorInfo(new ErrorInfo("Unable to configure proxy without proxy password", 40000, 400)); } + if (proxyPassword == null) { + throw AblyException.fromErrorInfo(new ErrorInfo("Unable to configure proxy without proxy password", 40000, 400)); + } proxyAuth = new HttpAuth(proxyUser, proxyPassword, proxyOptions.prefAuthType); } } @@ -67,6 +103,7 @@ public HttpCore(ClientOptions options, Auth auth, PlatformAgentProvider platform /** * Make a synchronous HTTP request specified by URL and proxy, retrying if necessary on WWW-Authenticate + * * @param url * @param method * @param headers @@ -77,21 +114,21 @@ public HttpCore(ClientOptions options, Auth auth, PlatformAgentProvider platform */ public T httpExecuteWithRetry(URL url, String method, Param[] headers, RequestBody requestBody, ResponseHandler responseHandler, boolean requireAblyAuth) throws AblyException { boolean renewPending = true, proxyAuthPending = true; - if(requireAblyAuth) { + if (requireAblyAuth) { authorize(false); } - while(true) { + while (true) { try { return httpExecute(url, getProxy(url), method, headers, requestBody, true, responseHandler); - } catch(AuthRequiredException are) { - if(are.authChallenge != null && requireAblyAuth) { - if(are.expired && renewPending) { + } catch (AuthRequiredException are) { + if (are.authChallenge != null && requireAblyAuth) { + if (are.expired && renewPending) { authorize(true); renewPending = false; continue; } } - if(are.proxyAuthChallenge != null && proxyAuthPending && proxyAuth != null) { + if (are.proxyAuthChallenge != null && proxyAuthPending && proxyAuth != null) { proxyAuth.processAuthenticateHeaders(are.proxyAuthChallenge); proxyAuthPending = false; continue; @@ -102,22 +139,21 @@ public T httpExecuteWithRetry(URL url, String method, Param[] headers, Reque } /** - * Sets host for this HTTP client + * Gets host for this HTTP client * - * @param host URL string + * @return */ - public void setPreferredHost(String host) { - hosts.setPreferredHost(host, false); + public String getPreferredHost() { + return hosts.getPreferredHost(); } /** - * Gets host for this HTTP client + * Sets host for this HTTP client * - * @return - + * @param host URL string */ - public String getPreferredHost() { - return hosts.getPreferredHost(); + public void setPreferredHost(String host) { + hosts.setPreferredHost(host, false); } /** @@ -139,6 +175,7 @@ void authorize(boolean renew) throws AblyException { /** * Make a synchronous HTTP request specified by URL and proxy + * * @param url * @param proxy * @param method @@ -152,13 +189,13 @@ void authorize(boolean renew) throws AblyException { public T httpExecute(URL url, Proxy proxy, String method, Param[] headers, RequestBody requestBody, boolean withCredentials, ResponseHandler responseHandler) throws AblyException { HttpURLConnection conn = null; try { - conn = (HttpURLConnection)url.openConnection(proxy); + conn = (HttpURLConnection) url.openConnection(proxy); boolean withProxyCredentials = (proxy != Proxy.NO_PROXY) && (proxyAuth != null); return httpExecute(conn, method, headers, requestBody, withCredentials, withProxyCredentials, responseHandler); - } catch(IOException ioe) { + } catch (IOException ioe) { throw AblyException.fromThrowable(ioe); } finally { - if(conn != null) { + if (conn != null) { conn.disconnect(); } } @@ -166,6 +203,7 @@ public T httpExecute(URL url, Proxy proxy, String method, Param[] headers, R /** * Make a synchronous HTTP request with a given HttpURLConnection + * * @param conn * @param method * @param headers @@ -191,32 +229,37 @@ T httpExecute(HttpURLConnection conn, String method, Param[] headers, Reques if (authHeader == null && auth != null) { authHeader = auth.getAuthorizationHeader(); } - if(withCredentials && authHeader != null) { + if (withCredentials && authHeader != null) { conn.setRequestProperty(HttpConstants.Headers.AUTHORIZATION, authHeader); credentialsIncluded = true; } - if(withProxyCredentials && proxyAuth.hasChallenge()) { + if (withProxyCredentials && proxyAuth.hasChallenge()) { byte[] encodedRequestBody = (requestBody != null) ? requestBody.getEncoded() : null; String proxyAuthorizationHeader = proxyAuth.getAuthorizationHeader(method, conn.getURL().getPath(), encodedRequestBody); conn.setRequestProperty(HttpConstants.Headers.PROXY_AUTHORIZATION, proxyAuthorizationHeader); } boolean acceptSet = false; - if(headers != null) { - for(Param header: headers) { + if (headers != null) { + for (Param header : headers) { conn.setRequestProperty(header.key, header.value); - if(header.key.equals(HttpConstants.Headers.ACCEPT)) { acceptSet = true; } + if (header.key.equals(HttpConstants.Headers.ACCEPT)) { + acceptSet = true; + } } } - if(!acceptSet) { conn.setRequestProperty(HttpConstants.Headers.ACCEPT, HttpConstants.ContentTypes.JSON); } + if (!acceptSet) { + conn.setRequestProperty(HttpConstants.Headers.ACCEPT, HttpConstants.ContentTypes.JSON); + } /* pass required headers */ conn.setRequestProperty(Defaults.ABLY_PROTOCOL_VERSION_HEADER, Defaults.ABLY_PROTOCOL_VERSION); // RSC7a conn.setRequestProperty(Defaults.ABLY_AGENT_HEADER, AgentHeaderCreator.create(options.agents, platformAgentProvider)); - if (options.clientId != null) conn.setRequestProperty(Defaults.ABLY_CLIENT_ID_HEADER, Base64Coder.encodeString(options.clientId)); + if (options.clientId != null) + conn.setRequestProperty(Defaults.ABLY_CLIENT_ID_HEADER, Base64Coder.encodeString(options.clientId)); /* prepare request body */ byte[] body = null; - if(requestBody != null) { + if (requestBody != null) { body = prepareRequestBody(requestBody, conn); // Check the logging level to avoid performance hit associated with building the message if (Log.level <= Log.VERBOSE) @@ -235,9 +278,9 @@ T httpExecute(HttpURLConnection conn, String method, Param[] headers, Reques Log.v(TAG, " " + entry.getKey() + ": " + val); } - if(options instanceof DebugOptions) { - rawHttpListener = ((DebugOptions)options).httpListener; - if(rawHttpListener != null) { + if (options instanceof DebugOptions) { + rawHttpListener = ((DebugOptions) options).httpListener; + if (rawHttpListener != null) { id = String.valueOf(Math.random()).substring(2); response = rawHttpListener.onRawHttpRequest(id, conn, method, (credentialsIncluded ? authHeader : null), requestProperties, requestBody); if (response != null) { @@ -247,15 +290,15 @@ T httpExecute(HttpURLConnection conn, String method, Param[] headers, Reques } /* send request body */ - if(requestBody != null) { + if (requestBody != null) { writeRequestBody(body, conn); } response = readResponse(conn); - if(rawHttpListener != null) { + if (rawHttpListener != null) { rawHttpListener.onRawHttpResponse(id, method, response); } - } catch(IOException ioe) { - if(rawHttpListener != null) { + } catch (IOException ioe) { + if (rawHttpListener != null) { rawHttpListener.onRawHttpException(id, method, ioe); } throw AblyException.fromThrowable(ioe); @@ -266,6 +309,7 @@ T httpExecute(HttpURLConnection conn, String method, Param[] headers, Reques /** * Handle HTTP response + * * @param conn * @param credentialsIncluded * @param response @@ -278,19 +322,19 @@ private T handleResponse(HttpURLConnection conn, boolean credentialsIncluded return null; } - if (response.statusCode >=500 && response.statusCode <= 504) { + if (response.statusCode >= 500 && response.statusCode <= 504) { ErrorInfo error = ErrorInfo.fromResponseStatus(response.statusLine, response.statusCode); throw AblyException.fromErrorInfo(error); } - if(response.statusCode >= 200 && response.statusCode < 300) { + if (response.statusCode >= 200 && response.statusCode < 300) { return (responseHandler != null) ? responseHandler.handleResponse(response, null) : null; } /* get any in-body error details */ ErrorInfo error = null; - if(response.body != null && response.body.length > 0) { - if(response.contentType != null && response.contentType.contains("msgpack")) { + if (response.body != null && response.body.length > 0) { + if (response.contentType != null && response.contentType.contains("msgpack")) { try { error = ErrorInfo.fromMsgpackBody(response.body); } catch (IOException e) { @@ -302,10 +346,10 @@ private T handleResponse(HttpURLConnection conn, boolean credentialsIncluded String bodyText = new String(response.body); try { ErrorResponse errorResponse = ErrorResponse.fromJSON(bodyText); - if(errorResponse != null) { + if (errorResponse != null) { error = errorResponse.error; } - } catch(JsonParseException jse) { + } catch (JsonParseException jse) { /* error pages aren't necessarily going to satisfy our Accept criteria ... */ System.err.println("Error message in unexpected format: " + bodyText); } @@ -313,50 +357,53 @@ private T handleResponse(HttpURLConnection conn, boolean credentialsIncluded } /* handle error details in header */ - if(error == null) { + if (error == null) { String errorCodeHeader = conn.getHeaderField("X-Ably-ErrorCode"); String errorMessageHeader = conn.getHeaderField("X-Ably-ErrorMessage"); - if(errorCodeHeader != null) { + if (errorCodeHeader != null) { try { error = new ErrorInfo(errorMessageHeader, response.statusCode, Integer.parseInt(errorCodeHeader)); - } catch(NumberFormatException e) {} + } catch (NumberFormatException e) { + } } } /* handle www-authenticate */ - if(response.statusCode == 401) { + if (response.statusCode == 401) { boolean stale = (error != null && error.code == 40140); List wwwAuthHeaders = response.getHeaderFields(HttpConstants.Headers.WWW_AUTHENTICATE); - if(wwwAuthHeaders != null && wwwAuthHeaders.size() > 0) { + if (wwwAuthHeaders != null && wwwAuthHeaders.size() > 0) { Map headersByType = HttpAuth.sortAuthenticateHeaders(wwwAuthHeaders); String tokenHeader = headersByType.get(HttpAuth.Type.X_ABLY_TOKEN); - if(tokenHeader != null) { stale |= (tokenHeader.indexOf("stale") > -1); } + if (tokenHeader != null) { + stale |= (tokenHeader.indexOf("stale") > -1); + } AuthRequiredException exception = new AuthRequiredException(null, error); exception.authChallenge = headersByType; - if(stale) { + if (stale) { exception.expired = true; throw exception; } - if(!credentialsIncluded) { + if (!credentialsIncluded) { throw exception; } } } /* handle proxy-authenticate */ - if(response.statusCode == 407) { + if (response.statusCode == 407) { List proxyAuthHeaders = response.getHeaderFields(HttpConstants.Headers.PROXY_AUTHENTICATE); - if(proxyAuthHeaders != null && proxyAuthHeaders.size() > 0) { + if (proxyAuthHeaders != null && proxyAuthHeaders.size() > 0) { AuthRequiredException exception = new AuthRequiredException(null, error); exception.proxyAuthChallenge = HttpAuth.sortAuthenticateHeaders(proxyAuthHeaders); throw exception; } } - if(error == null) { + if (error == null) { error = ErrorInfo.fromResponseStatus(response.statusLine, response.statusCode); } else { } - Log.e(TAG, "Error response from server: err = " + error.toString()); - if(responseHandler != null) { + Log.e(TAG, "Error response from server: err = " + error); + if (responseHandler != null) { return responseHandler.handleResponse(response, error); } throw AblyException.fromErrorInfo(error); @@ -364,6 +411,7 @@ private T handleResponse(HttpURLConnection conn, boolean credentialsIncluded /** * Emit the request body for an HTTP request + * * @param requestBody * @param conn * @return body @@ -386,6 +434,7 @@ private void writeRequestBody(byte[] body, HttpURLConnection conn) throws IOExce /** * Read the response for an HTTP request + * * @param connection * @return * @throws IOException @@ -410,7 +459,7 @@ private Response readResponse(HttpURLConnection connection) throws IOException { } } - if(response.statusCode == HttpURLConnection.HTTP_NO_CONTENT) { + if (response.statusCode == HttpURLConnection.HTTP_NO_CONTENT) { return response; } @@ -420,7 +469,8 @@ private Response readResponse(HttpURLConnection connection) throws IOException { InputStream is = null; try { is = connection.getInputStream(); - } catch (Throwable e) {} + } catch (Throwable e) { + } if (is == null) is = connection.getErrorStream(); @@ -433,7 +483,8 @@ private Response readResponse(HttpURLConnection connection) throws IOException { if (is != null) { try { is.close(); - } catch (IOException e) {} + } catch (IOException e) { + } } } @@ -451,16 +502,15 @@ private byte[] readInputStream(InputStream inputStream, int bytes) throws IOExce if (bytes == -1) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); byte[] buffer = new byte[4 * 1024]; - while((bytesRead = inputStream.read(buffer)) > -1) { + while ((bytesRead = inputStream.read(buffer)) > -1) { outputStream.write(buffer, 0, bytesRead); } return outputStream.toByteArray(); - } - else { + } else { int idx = 0; byte[] output = new byte[bytes]; - while((bytesRead = inputStream.read(output, idx, bytes - idx)) > -1) { + while ((bytesRead = inputStream.read(output, idx, bytes - idx)) > -1) { idx += bytesRead; } @@ -474,11 +524,11 @@ Proxy getProxy(URL url) { } private Proxy getProxy(String host) { - if(proxyOptions != null) { + if (proxyOptions != null) { String[] nonProxyHosts = proxyOptions.nonProxyHosts; - if(nonProxyHosts != null) { - for(String nonProxyHostPattern : nonProxyHosts) { - if(host.matches(nonProxyHostPattern)) { + if (nonProxyHosts != null) { + for (String nonProxyHostPattern : nonProxyHosts) { + if (host.matches(nonProxyHostPattern)) { return null; } } @@ -487,47 +537,18 @@ private Proxy getProxy(String host) { return proxy; } - /************************* - * Private state - *************************/ - - static { - /* if on Android, check version */ - Field androidVersionField = null; - int androidVersion = 0; - try { - androidVersionField = Class.forName("android.os.Build$VERSION").getField("SDK_INT"); - androidVersion = androidVersionField.getInt(androidVersionField); - } catch (Exception e) {} - if(androidVersionField != null && androidVersion < 8) { - /* HTTP connection reuse which was buggy pre-froyo */ - System.setProperty("httpCore.keepAlive", "false"); - } - } - - public final String scheme; - public final int port; - final ClientOptions options; - final Hosts hosts; - - private final Auth auth; - private final ProxyOptions proxyOptions; - private HttpAuth proxyAuth; - private Proxy proxy = Proxy.NO_PROXY; - private final PlatformAgentProvider platformAgentProvider; - - private static final String TAG = HttpCore.class.getName(); - /** * Interface for an entity that supplies an httpCore request body */ public interface RequestBody { byte[] getEncoded(); + String getContentType(); } /** * Interface for an entity that performs type-specific processing on an httpCore response body + * * @param */ public interface BodyHandler { @@ -536,6 +557,7 @@ public interface BodyHandler { /** * Interface for an entity that performs type-specific processing on an httpCore response + * * @param */ public interface ResponseHandler { @@ -548,7 +570,7 @@ public interface ResponseHandler { public static class Response { public int statusCode; public String statusLine; - public Map> headers; + public Map> headers; public String contentType; public int contentLength; public byte[] body; @@ -559,13 +581,12 @@ public static class Response { * If called on a connection that sets the same header multiple times * with possibly different values, only the last value is returned. * - * - * @param name the name of a header field. - * @return the value of the named header field, or {@code null} - * if there is no such field in the header. + * @param name the name of a header field. + * @return the value of the named header field, or {@code null} + * if there is no such field in the header. */ public List getHeaderFields(String name) { - if(headers == null) { + if (headers == null) { return null; } @@ -578,11 +599,12 @@ public List getHeaderFields(String name) { */ public static class AuthRequiredException extends AblyException { private static final long serialVersionUID = 1L; - public AuthRequiredException(Throwable throwable, ErrorInfo reason) { - super(throwable, reason); - } public boolean expired; public Map authChallenge; public Map proxyAuthChallenge; + + public AuthRequiredException(Throwable throwable, ErrorInfo reason) { + super(throwable, reason); + } } } diff --git a/lib/src/main/java/io/ably/lib/transport/WebSocketTransport.java b/lib/src/main/java/io/ably/lib/transport/WebSocketTransport.java index ba3399b7e..c389be18c 100644 --- a/lib/src/main/java/io/ably/lib/transport/WebSocketTransport.java +++ b/lib/src/main/java/io/ably/lib/transport/WebSocketTransport.java @@ -7,39 +7,50 @@ import io.ably.lib.types.ProtocolMessage; import io.ably.lib.types.ProtocolSerializer; import io.ably.lib.util.Log; - -import java.net.URI; -import java.nio.ByteBuffer; -import java.util.Timer; -import java.util.TimerTask; - -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLParameters; -import javax.net.ssl.SSLSession; - +import org.java_websocket.WebSocket; import org.java_websocket.client.WebSocketClient; import org.java_websocket.exceptions.WebsocketNotConnectedException; import org.java_websocket.framing.CloseFrame; import org.java_websocket.framing.Framedata; import org.java_websocket.handshake.ServerHandshake; -import org.java_websocket.WebSocket; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLSession; +import java.net.URI; +import java.nio.ByteBuffer; +import java.util.Timer; +import java.util.TimerTask; public class WebSocketTransport implements ITransport { private static final String TAG = WebSocketTransport.class.getName(); - + private static final int NEVER_CONNECTED = -1; + private static final int BUGGYCLOSE = -2; + private static final int CLOSE_NORMAL = 1000; + private static final int GOING_AWAY = 1001; + private static final int CLOSE_PROTOCOL_ERROR = 1002; + private static final int REFUSE = 1003; + /* private static final int UNUSED = 1004; */ + /* private static final int NOCODE = 1005; */ + private static final int ABNORMAL_CLOSE = 1006; + private static final int NO_UTF8 = 1007; + private static final int POLICY_VALIDATION = 1008; + private static final int TOOBIG = 1009; + private static final int EXTENSION = 1010; + private static final int UNEXPECTED_CONDITION = 1011; + private static final int TLS_ERROR = 1015; /****************** - * public factory API + * private members ******************/ - public static class Factory implements ITransport.Factory { - @Override - public WebSocketTransport getTransport(TransportParams params, ConnectionManager connectionManager) { - return new WebSocketTransport(params, connectionManager); - } - } - + private final TransportParams params; + private final ConnectionManager connectionManager; + private final boolean channelBinaryMode; + private String wsUri; + private ConnectListener connectListener; + private WsClient wsConnection; /****************** * protected constructor ******************/ @@ -65,24 +76,24 @@ public void connect(ConnectListener connectListener) { wsUri = wsScheme + params.host + ':' + params.port + "/"; Param[] authParams = connectionManager.ably.auth.getAuthParams(); Param[] connectParams = params.getConnectParams(authParams); - if(connectParams.length > 0) + if (connectParams.length > 0) wsUri = HttpUtils.encodeParams(wsUri, connectParams); Log.d(TAG, "connect(); wsUri = " + wsUri); - synchronized(this) { + synchronized (this) { wsConnection = new WsClient(URI.create(wsUri), this::receive); - if(isTls) { + if (isTls) { SSLContext sslContext = SSLContext.getInstance("TLS"); - sslContext.init( null, null, null ); + sslContext.init(null, null, null); SafeSSLSocketFactory factory = new SafeSSLSocketFactory(sslContext.getSocketFactory()); wsConnection.setSocketFactory(factory); } } wsConnection.connect(); - } catch(AblyException e) { + } catch (AblyException e) { Log.e(TAG, "Unexpected exception attempting connection; wsUri = " + wsUri, e); connectListener.onTransportUnavailable(this, e.errorInfo); - } catch(Throwable t) { + } catch (Throwable t) { Log.e(TAG, "Unexpected exception attempting connection; wsUri = " + wsUri, t); connectListener.onTransportUnavailable(this, AblyException.fromThrowable(t).errorInfo); } @@ -91,8 +102,8 @@ public void connect(ConnectListener connectListener) { @Override public void close() { Log.d(TAG, "close()"); - synchronized(this) { - if(wsConnection != null) { + synchronized (this) { + if (wsConnection != null) { wsConnection.close(); wsConnection = null; } @@ -108,7 +119,7 @@ public void receive(ProtocolMessage msg) throws AblyException { public void send(ProtocolMessage msg) throws AblyException { Log.d(TAG, "send(); action = " + msg.action); try { - if(channelBinaryMode) { + if (channelBinaryMode) { byte[] encodedMsg = ProtocolSerializer.writeMsgpack(msg); // Check the logging level to avoid performance hit associated with building the message @@ -123,14 +134,12 @@ public void send(ProtocolMessage msg) throws AblyException { Log.v(TAG, "send(): " + new String(ProtocolSerializer.writeJSON(msg))); wsConnection.send(ProtocolSerializer.writeJSON(msg)); } - } - catch (WebsocketNotConnectedException e){ - if(connectListener != null) { + } catch (WebsocketNotConnectedException e) { + if (connectListener != null) { connectListener.onTransportUnavailable(this, AblyException.fromThrowable(e).errorInfo); } else throw AblyException.fromThrowable(e); - } - catch (Exception e) { + } catch (Exception e) { throw AblyException.fromThrowable(e); } } @@ -140,22 +149,47 @@ public String getHost() { return params.host; } - protected void preProcessReceivedMessage(ProtocolMessage message) - { + protected void preProcessReceivedMessage(ProtocolMessage message) { //Gives the chance to child classes to do message pre-processing } + public String toString() { + return WebSocketTransport.class.getName() + " {" + getURL() + "}"; + } + + public String getURL() { + return wsUri; + } //interface to transfer Protocol message from websocket interface WebSocketReceiver { void onMessage(ProtocolMessage protocolMessage) throws AblyException; } + /****************** + * public factory API + ******************/ + + public static class Factory implements ITransport.Factory { + @Override + public WebSocketTransport getTransport(TransportParams params, ConnectionManager connectionManager) { + return new WebSocketTransport(params, connectionManager); + } + } + /************************** * WebSocketHandler methods **************************/ - class WsClient extends WebSocketClient { - private final WebSocketReceiver receiver; + class WsClient extends WebSocketClient { + private final WebSocketReceiver receiver; + /*************************** + * WsClient private members + ***************************/ + + private Timer timer = new Timer(); + private TimerTask activityTimerTask = null; + private long lastActivityTime; + private boolean shouldExplicitlyVerifyHostname = true; WsClient(URI serverUri, WebSocketReceiver receiver) { super(serverUri); @@ -219,10 +253,10 @@ public void onMessage(String string) { /* This allows us to detect a websocket ping, so we don't need Ably pings. */ @Override - public void onWebsocketPing( WebSocket conn, Framedata f ) { + public void onWebsocketPing(WebSocket conn, Framedata f) { Log.d(TAG, "onWebsocketPing()"); /* Call superclass to ensure the pong is sent. */ - super.onWebsocketPing( conn, f ); + super.onWebsocketPing(conn, f); flagActivity(); } @@ -231,7 +265,7 @@ public void onClose(final int wsCode, final String wsReason, final boolean remot Log.d(TAG, "onClose(): wsCode = " + wsCode + "; wsReason = " + wsReason + "; remote = " + remote); ErrorInfo reason; - switch(wsCode) { + switch (wsCode) { case NEVER_CONNECTED: case CLOSE_NORMAL: case BUGGYCLOSE: @@ -291,7 +325,8 @@ private synchronized void dispose() { try { timer.cancel(); timer = null; - } catch(IllegalStateException e) {} + } catch (IllegalStateException e) { + } } private synchronized void flagActivity() { @@ -324,15 +359,13 @@ private synchronized void checkActivity() { startActivityTimer(timeout + 100); } - - private synchronized void startActivityTimer(long timeout) - { + private synchronized void startActivityTimer(long timeout) { if (activityTimerTask == null) { schedule((activityTimerTask = new TimerTask() { public void run() { try { onActivityTimerExpiry(); - } catch(Throwable t) { + } catch (Throwable t) { Log.e(TAG, "Unexpected exception in activity timer handler", t); } } @@ -341,17 +374,16 @@ public void run() { } private synchronized void schedule(TimerTask task, long delay) { - if(timer != null) { + if (timer != null) { try { timer.schedule(task, delay); - } catch(IllegalStateException ise) { + } catch (IllegalStateException ise) { Log.e(TAG, "Unexpected exception scheduling activity timer", ise); } } } - private synchronized void onActivityTimerExpiry() - { + private synchronized void onActivityTimerExpiry() { activityTimerTask = null; long timeSinceLastActivity = System.currentTimeMillis() - lastActivityTime; long timeRemaining = getActivityTimeout() - timeSinceLastActivity; @@ -368,55 +400,9 @@ private synchronized void onActivityTimerExpiry() startActivityTimer(timeRemaining + 100); } - private long getActivityTimeout() - { + private long getActivityTimeout() { return connectionManager.maxIdleInterval + connectionManager.ably.options.realtimeRequestTimeout; } - - /*************************** - * WsClient private members - ***************************/ - - private Timer timer = new Timer(); - private TimerTask activityTimerTask = null; - private long lastActivityTime; - private boolean shouldExplicitlyVerifyHostname = true; } - public String toString() { - return WebSocketTransport.class.getName() + " {" + getURL() + "}"; - } - - public String getURL() { - return wsUri; - } - - /****************** - * private members - ******************/ - - private final TransportParams params; - private final ConnectionManager connectionManager; - private final boolean channelBinaryMode; - private String wsUri; - private ConnectListener connectListener; - - private WsClient wsConnection; - - private static final int NEVER_CONNECTED = -1; - private static final int BUGGYCLOSE = -2; - private static final int CLOSE_NORMAL = 1000; - private static final int GOING_AWAY = 1001; - private static final int CLOSE_PROTOCOL_ERROR = 1002; - private static final int REFUSE = 1003; -/* private static final int UNUSED = 1004; */ -/* private static final int NOCODE = 1005; */ - private static final int ABNORMAL_CLOSE = 1006; - private static final int NO_UTF8 = 1007; - private static final int POLICY_VALIDATION = 1008; - private static final int TOOBIG = 1009; - private static final int EXTENSION = 1010; - private static final int UNEXPECTED_CONDITION = 1011; - private static final int TLS_ERROR = 1015; - } diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 9ee5ac941..000000000 --- a/settings.gradle +++ /dev/null @@ -1,4 +0,0 @@ -rootProject.name = 'ably-java' -include 'java', - 'android', - 'gradle-lint' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..220fd80b7 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,13 @@ +pluginManagement { + repositories { + google() + gradlePluginPortal() + mavenCentral() + } +} + +rootProject.name = "ably-java" + +include("java") +include("android") +include("gradle-lint")