Skip to content

Commit

Permalink
feat!: BCV 0.15.0, Kotlin 2.0
Browse files Browse the repository at this point in the history
Signed-off-by: Art Shendrik <[email protected]>
  • Loading branch information
amal committed Jun 8, 2024
1 parent 5849885 commit 84e4f16
Show file tree
Hide file tree
Showing 43 changed files with 1,577 additions and 1,862 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="detektBaseline" type="GradleRunConfiguration" factoryName="Gradle" folderName="baseline">
<configuration default="false" name="detektBaselineMerge" type="GradleRunConfiguration" factoryName="Gradle" folderName="baseline">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
Expand All @@ -10,7 +10,7 @@
</option>
<option name="taskNames">
<list>
<option value="detektBaseline" />
<option value="detektBaselineMerge" />
</list>
</option>
<option name="vmOptions" />
Expand Down
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@

[//]: # (Changed, Added, Removed, Fixed, Updated)

### Updated
- **bump Kotlin to _2.0.0_**.
- **bump latest supported [BCV][bcv] to _0.15.0-Beta.2_**.

### Changed
- change JS in the plugin name and class package to TS. Plugin ID is unchanged!

### Added
- add support for the configurable api dump directory appeared in [BCV][bcv] _0.14.0_.

### Changed
- Rename "JS" references to "TS" to avoid collisions with [BCV][bcv] _0.15.0_.
Changed task names, log messages, and documentation.


## [0.3.0] - 2024-04-28

Expand Down Expand Up @@ -33,7 +47,7 @@ _Minor update release._
🌱 _First stable release._

### Added
- Add Kotlin/JS API support to the KotlinX [Binary Compatibility Validator][bcv] based on the generated TS definitions.
- Add Kotlin/TypeScript API support to the KotlinX [Binary Compatibility Validator][bcv] based on the generated TS definitions.
Fixes [Kotlin/binary-compatibility-validator#42](https://github.com/Kotlin/binary-compatibility-validator/issues/42)
- Add support for Kotlin/JS non-KMP projects.
- Add compatibility with [BCV][bcv] 0.8+
Expand Down
43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
# Fluxo-BCV-JS
## Binary Compatibility Validator for Kotlin/JS by [Fluxo][fluxo]
# Fluxo-BCV-TS
## Binary Compatibility Validator for Kotlin/TypeScript definitions (JS, WASM targets)

[![Gradle Plugin Portal][badge-plugin]][plugin]
[![JitPack][badge-jitpack]][jitpack]
[![Build](../../actions/workflows/build.yml/badge.svg)](../../actions/workflows/build.yml)
[![Common Changelog](https://common-changelog.org/badge.svg)](CHANGELOG.md)

[![KotlinX BCV Compatibility](http://img.shields.io/badge/KotlinX%20BCV-0.8%20--%200.14-7F52FF?logo=kotlin&logoWidth=10&logoColor=7F52FF&labelColor=2B2B2B)][bcv]
[![KotlinX BCV Compatibility](http://img.shields.io/badge/KotlinX%20BCV-0.8%20--%200.15-7F52FF?logo=kotlin&logoWidth=10&logoColor=7F52FF&labelColor=2B2B2B)][bcv]
[![Kotlin Compatibility](http://img.shields.io/badge/Kotlin-1.6.20+-7F52FF?logo=kotlin&logoWidth=10&logoColor=7F52FF&labelColor=2B2B2B)](https://github.com/JetBrains/Kotlin)
[![Gradle Compatibility](http://img.shields.io/badge/Gradle-7.6+-f68244?logo=gradle&labelColor=2B2B2B)](https://gradle.org/releases/)

A tiny Gradle plugin that adds JS/TS API support to the
A tiny Gradle plugin that adds TypeScript (JS) API support to the
KotlinX [Binary Compatibility Validator][bcv] (BCV).

Can be used with any Gradle module with **Kotlin/JS** target.
Can be used with any Gradle module with **Kotlin/JS** or **Kotlin/WASM** target.
Either [Kotlin Multiplatform][KMM] or [Kotlin/JS][KJS].

Integrates well with the default BCV pipeline, providing more features with same Gradle tasks.
Doesn't conflict with the KLIB API dumps.

Integrates with the default BCV pipeline, providing more features for the same Gradle tasks.

As [mentioned](https://github.com/Kotlin/binary-compatibility-validator/issues/42#issuecomment-1435031047)
in the Kotlin/binary-compatibility-validator#42, the Kotlin team is not yet ready to accept
a contribution for JS/TS support, or even to do due diligence
and see if this is a reasonable addition for the future.

The tool allows dumping TypeScript definitions of a JS part of a Kotlin multiplatform library
that's public in the sense of npm package visibility, and ensures that the public definitions
haven't been changed in a way that makes this change binary incompatible.
The tool allows dumping TypeScript definitions of a JS or WASM part
of a Kotlin multiplatform library that's public in the sense
of npm package visibility.
And ensures that the public definitions haven't been changed in a way
that makes this change binary incompatible.

This plugin will be supported until the official Kotlin/JS support is added to [BCV][bcv].

Expand All @@ -35,11 +39,12 @@ but then published for general use.

### Compatibility

Kotlin supports generation of TypeScript declarations [since 1.6.20](https://kotlinlang.org/docs/whatsnew1620.html#improvements-to-export-and-typescript-declaration-generation)
Kotlin has supported generation of TypeScript declarations [since 1.6.20](https://kotlinlang.org/docs/whatsnew1620.html#improvements-to-export-and-typescript-declaration-generation).
Compatibility tested with:

| Version | BCV | Kotlin | Gradle |
|:-------:|:----------:|:-------:|:------:|
| 1.0.0 | 0.8 - 0.15 | 1.6.20+ | 7.6+ |
| 0.3.0 | 0.8 - 0.14 | 1.6.20+ | 7.6+ |
| 0.2.0 | 0.8 - 0.13 | 1.6.20+ | 7.4+ |

Expand All @@ -49,10 +54,10 @@ Compatibility tested with:
[![Gradle Plugin Portal][badge-plugin]][plugin]

```kotlin
// in the `build.gradle.kts` of the target module
// in the `build.gradle.kts` of the target module.
plugins {
kotlin("multiplatform") version "1.9.23" // <-- multiplatform or js, versions from 1.6.20 to 1.9
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.14.0" // <-- 0.8 .. 0.13
kotlin("multiplatform") version "2.0.0" // <-- versions from 1.6.20 to 2.0
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.14.0" // <-- 0.8 .. 0.15
id("io.github.fluxo-kt.binary-compatibility-validator-js") version "0.3.0" // <-- add here
}
kotlin {
Expand All @@ -69,10 +74,10 @@ kotlin {
[![JitPack][badge-jitpack]][jitpack]

```kotlin
// in the `build.gradle.kts` of the target module
// in the `build.gradle.kts` of the target module.
plugins {
kotlin("multiplatform") version "1.9.23" // <-- multiplatform or js, versions from 1.6.20 to 1.9
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2" // <-- 0.8 .. 0.13
kotlin("multiplatform") version "2.0.0" // <-- versions from 1.6.20 to 2.0
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.14.0" // <-- 0.8 .. 0.15
id("io.github.fluxo-kt.binary-compatibility-validator-js") // <-- add here, no version needed for jitpack usage
}
kotlin {
Expand All @@ -91,15 +96,15 @@ pluginManagement {
}
resolutionStrategy.eachPlugin {
if (requested.id.toString() == "io.github.fluxo-kt.binary-compatibility-validator-js")
useModule("com.github.fluxo-kt.fluxo-bcv-js:fluxo-bcv-js:8fc3b62961") // <-- specify version or commit
useModule("com.github.fluxo-kt.fluxo-bcv-js:fluxo-bcv-js:8fc3b62961") // <-- specify a version, or a commit.
}
}
```
</details>

Module examples for:
- [Kotlin Multiplatform](checks/latest/build.gradle.kts)
- [Kotlin/JS](checks/js-only/build.gradle.kts)
- [Latest setup](checks/latest/build.gradle.kts)
- [Oldest setup](checks/js-only/build.gradle.kts)


### Versioning
Expand Down
14 changes: 0 additions & 14 deletions baseline

This file was deleted.

2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.sam.receiver) apply false
alias(libs.plugins.kotlinx.binCompatValidator) apply false
alias(libs.plugins.android.lint) apply false
alias(libs.plugins.deps.guard) apply false
alias(libs.plugins.gradle.doctor) apply false
alias(libs.plugins.gradle.plugin.publish) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.fluxo.conf)
Expand Down
7 changes: 3 additions & 4 deletions checks/js-only/dependencies/classpath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ org.jetbrains.kotlin:kotlin-scripting-common:1.6.21
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.6.21
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.6.21
org.jetbrains.kotlin:kotlin-scripting-jvm:1.6.21
org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10
org.jetbrains.kotlin:kotlin-stdlib:1.7.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0
org.jetbrains.kotlin:kotlin-stdlib:1.9.20
org.jetbrains.kotlin:kotlin-tooling-metadata:1.6.21
org.jetbrains.kotlin:kotlin-util-io:1.6.21
org.jetbrains.kotlin:kotlin-util-klib:1.6.21
Expand Down
4 changes: 2 additions & 2 deletions checks/js-only/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# https://gradle.org/release-checksums/
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=bed1da33cca0f557ab13691c77f38bb67388119e4794d113e051039b80af9bb1
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
distributionSha256Sum=9631d53cf3e74bfa726893aee1f8994fee4e060c401335946dba2156f440f24c
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
31 changes: 18 additions & 13 deletions checks/js-only/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# 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" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# 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" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions checks/js-only/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
1 change: 0 additions & 1 deletion checks/js-only/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
includeBuild("../../")
Expand Down
14 changes: 5 additions & 9 deletions checks/latest/api/check-latest.api
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
public final class example/ExampleDataClass {
public fun <init> (I)V
public final fun component1 ()I
public final fun copy (I)Lexample/ExampleDataClass;
public static synthetic fun copy$default (Lexample/ExampleDataClass;IILjava/lang/Object;)Lexample/ExampleDataClass;
public fun equals (Ljava/lang/Object;)Z
public final fun getValue ()I
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public final class example/ExampleKt {
public static final fun addOne (I)I
public static final fun d2f (D)F
public static final fun dummy ()V
public static final fun s2b (Ljava/lang/String;)Z
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
type Nullable<T> = T | null | undefined
export declare namespace example {
function addOne(x: number): number;
function d2f(f: number): number;
function s2b(s: string): boolean;
function dummy(): void;
}
export declare namespace example {
class ExampleDataClass {
constructor(value: number);
Expand Down
23 changes: 23 additions & 0 deletions checks/latest/api/check-latest.klib.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Klib ABI Dump
// Targets: [js, linuxX64, wasmJs, wasmWasi]
// Rendering settings:
// - Signature version: 2
// - Show manifest properties: true
// - Show declarations: true

// Library unique name: <check-latest>
final fun example/addOne(kotlin/Int): kotlin/Int // example/addOne|addOne(kotlin.Int){}[0]
final fun example/d2f(kotlin/Double): kotlin/Float // example/d2f|d2f(kotlin.Double){}[0]
final fun example/dummy() // example/dummy|dummy(){}[0]
final fun example/s2b(kotlin/String): kotlin/Boolean // example/s2b|s2b(kotlin.String){}[0]
// Targets: [js]
final class example/ExampleDataClass { // example/ExampleDataClass|null[0]
constructor <init>(kotlin/Int) // example/ExampleDataClass.<init>|<init>(kotlin.Int){}[0]
final fun component1(): kotlin/Int // example/ExampleDataClass.component1|component1(){}[0]
final fun copy(kotlin/Int = ...): example/ExampleDataClass // example/ExampleDataClass.copy|copy(kotlin.Int){}[0]
final fun equals(kotlin/Any?): kotlin/Boolean // example/ExampleDataClass.equals|equals(kotlin.Any?){}[0]
final fun hashCode(): kotlin/Int // example/ExampleDataClass.hashCode|hashCode(){}[0]
final fun toString(): kotlin/String // example/ExampleDataClass.toString|toString(){}[0]
final val value // example/ExampleDataClass.value|{}value[0]
final fun <get-value>(): kotlin/Int // example/ExampleDataClass.value.<get-value>|<get-value>(){}[0]
}
5 changes: 5 additions & 0 deletions checks/latest/api/check-latest.wasmJs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Nullable<T> = T | null | undefined
export declare function addOne(x: number): number;
export declare function d2f(f: number): number;
export declare function s2b(s: string): boolean;
export declare function dummy(): void;
Loading

0 comments on commit 84e4f16

Please sign in to comment.