From d7b03aed507cab2188c6ea04794ba8b989cddf6b Mon Sep 17 00:00:00 2001 From: Mouaad Aallam Date: Mon, 27 Feb 2023 16:58:45 +0100 Subject: [PATCH] chore(java): add api compat check (#1335) --- .github/.cache_version | 2 +- .github/workflows/check.yml | 4 ++ .gitignore | 1 + .../api/build.gradle | 39 +++++++++++++++++++ .../settings.gradle | 3 ++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 clients/algoliasearch-client-java-2/api/build.gradle diff --git a/.github/.cache_version b/.github/.cache_version index cd23180456..32786aa437 100644 --- a/.github/.cache_version +++ b/.github/.cache_version @@ -1 +1 @@ -0.0.17 +0.0.18 diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index afd1140995..5073c54454 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -232,6 +232,10 @@ jobs: if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'javascript' && contains(matrix.client.toRun,'algoliasearch') }} run: cd ${{ matrix.client.path }} && yarn workspace algoliasearch test + - name: Run Java 'algoliasearch' public API validation + if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'java' }} + run: cd ${{ matrix.client.path }} && ./gradlew :api:japicmp + - name: Remove previous CTS output run: rm -rf ${{ matrix.client.testsToDelete }} || true diff --git a/.gitignore b/.gitignore index 821ea6e9d9..c0a5592605 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ dist generators/bin +**/java/bin/ diff --git a/clients/algoliasearch-client-java-2/api/build.gradle b/clients/algoliasearch-client-java-2/api/build.gradle new file mode 100644 index 0000000000..104f22ac3e --- /dev/null +++ b/clients/algoliasearch-client-java-2/api/build.gradle @@ -0,0 +1,39 @@ +// This package is to check the public API (binary) compatibility of the latest +// published release with `algoliasearch-client-java` package. + +import me.champeau.gradle.japicmp.JapicmpTask + +plugins { + id 'java-library' + id 'me.champeau.gradle.japicmp' version '0.4.1' +} + +repositories { + maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } + mavenCentral() +} + +def baselineConfig = configurations.register('baseline') +def latestConfig = configurations.register('latest') + +dependencies { + baseline('com.algolia:algoliasearch-client-java:4.+') { + transitive = false + } + latest(projects.algoliasearchCore) +} + +def japicmp = tasks.register('japicmp', JapicmpTask) { + dependsOn tasks.findByName("jar") + oldClasspath.setFrom(baselineConfig) + newClasspath.setFrom(latestConfig) + onlyBinaryIncompatibleModified.set(true) + failOnModification.set(true) + txtOutputFile.set(file("$buildDir/reports/japi.txt")) + ignoreMissingClasses.set(true) + includeSynthetic.set(true) +} + +tasks.findByName('check').configure { + dependsOn japicmp +} diff --git a/clients/algoliasearch-client-java-2/settings.gradle b/clients/algoliasearch-client-java-2/settings.gradle index b60cb778ab..b39f066aa5 100644 --- a/clients/algoliasearch-client-java-2/settings.gradle +++ b/clients/algoliasearch-client-java-2/settings.gradle @@ -1,3 +1,6 @@ rootProject.name = "algoliasearch-client-java" include(":algoliasearch-core") +include(":api") + +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")