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..9cddab77b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,20 @@ +GROUP=io.ably +VERSION_NAME=1.2.43 + +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/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")