Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add klib api validation #74

Merged
merged 6 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
java-version: [ 11, 19 ]

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -46,20 +47,39 @@ jobs:
uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: 11
java-version: ${{ matrix.java-version }}

- name: Check API Compatibility
if: matrix.os == 'macos-latest' && matrix.java-version == 19
run: >
./gradlew apiCheck --stacktrace

- name: Run macOS Tests
if: matrix.os == 'macos-latest'
if: matrix.os == 'macos-latest' && matrix.java-version == 19
run: >
./gradlew check --stacktrace
-PKMP_TARGETS="JVM,IOS_ARM64,IOS_X64,IOS_SIMULATOR_ARM64,MACOS_ARM64,MACOS_X64,TVOS_ARM64,TVOS_X64,TVOS_SIMULATOR_ARM64,WATCHOS_ARM32,WATCHOS_ARM64,WATCHOS_DEVICE_ARM64,WATCHOS_X64,WATCHOS_SIMULATOR_ARM64"

- name: Run macOS Java11 Tests
if: matrix.os == 'macos-latest' && matrix.java-version == 11
run: >
./gradlew check --stacktrace
-PKMP_TARGETS="JVM,JS,IOS_ARM64,IOS_X64,IOS_SIMULATOR_ARM64,MACOS_ARM64,MACOS_X64,TVOS_ARM64,TVOS_X64,TVOS_SIMULATOR_ARM64,WATCHOS_ARM32,WATCHOS_ARM64,WATCHOS_DEVICE_ARM64,WATCHOS_X64,WATCHOS_SIMULATOR_ARM64,WASM_JS,WASM_WASI"
-PKMP_TARGETS="JS,JVM,WASM_JS,WASM_WASI"

- name: Run Linux Tests
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-latest' && matrix.java-version == 19
run: >
./gradlew check --stacktrace
-PKMP_TARGETS="JVM,JS,ANDROID_ARM32,ANDROID_ARM64,ANDROID_X64,ANDROID_X86,LINUX_ARM64,LINUX_X64,WASM_JS,WASM_WASI"
-PKMP_TARGETS="ANDROID,ANDROID_ARM32,ANDROID_ARM64,ANDROID_X64,ANDROID_X86,JVM,LINUX_ARM64,LINUX_X64"

- name: Run Linux Java11 Tests
if: matrix.os == 'ubuntu-latest' && matrix.java-version == 11
run: >
./gradlew check --stacktrace
-PKMP_TARGETS="JS,JVM,WASM_JS,WASM_WASI"

- name: Run Windows Tests
if: matrix.os == 'windows-latest'
if: matrix.os == 'windows-latest' && matrix.java-version == 11
run: >
./gradlew check --stacktrace
-PKMP_TARGETS="JVM,JS,MINGW_X64,WASM_JS,WASM_WASI"
Expand Down
1 change: 0 additions & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ plugins {
}

dependencies {
implementation(libs.gradle.android)
implementation(libs.gradle.kmp.configuration)
implementation(libs.gradle.kotlin)
implementation(libs.gradle.publish.maven)
Expand Down
1 change: 0 additions & 1 deletion build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ rootProject.name = "build-logic"
dependencyResolutionManagement {
repositories {
mavenCentral()
google()
gradlePluginPortal()
}

Expand Down
15 changes: 14 additions & 1 deletion build-logic/src/main/kotlin/-KmpConfigurationExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import io.matthewnelson.kmp.configuration.ExperimentalKmpConfigurationApi
import io.matthewnelson.kmp.configuration.extension.KmpConfigurationExtension
import io.matthewnelson.kmp.configuration.extension.container.target.KmpConfigurationContainerDsl
import org.gradle.api.Action
import org.gradle.api.JavaVersion

fun KmpConfigurationExtension.configureShared(
java9ModuleName: String? = null,
publish: Boolean = false,
action: Action<KmpConfigurationContainerDsl>,
) {
if (publish) {
require(!java9ModuleName.isNullOrBlank()) { "publications must specify a module-info name" }
}

configure {
options {
useUniqueModuleNames = true
}

jvm {
kotlinJvmTarget = JavaVersion.VERSION_1_8
compileSourceCompatibility = JavaVersion.VERSION_1_8
compileTargetCompatibility = JavaVersion.VERSION_1_8

@OptIn(ExperimentalKmpConfigurationApi::class)
java9ModuleInfoName = java9ModuleName
}

js {
Expand Down Expand Up @@ -57,7 +70,7 @@ fun KmpConfigurationExtension.configureShared(
}
}

kotlin { explicitApi() }
if (publish) kotlin { explicitApi() }

action.execute(this)
}
Expand Down
11 changes: 6 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,17 @@ plugins {
}

allprojects {

findProperty("GROUP")?.let { group = it }
findProperty("VERSION_NAME")?.let { version = it }
findProperty("POM_DESCRIPTION")?.let { description = it.toString() }

repositories {
mavenCentral()
google()
gradlePluginPortal()
}

}

@Suppress("PropertyName")
val CHECK_PUBLICATION = findProperty("CHECK_PUBLICATION") as? String
val CHECK_PUBLICATION = findProperty("CHECK_PUBLICATION")

plugins.withType<YarnPlugin> {
the<YarnRootExtension>().lockFileDirectory = rootDir.resolve(".kotlin-js-store")
Expand All @@ -48,6 +44,11 @@ plugins.withType<YarnPlugin> {
}

apiValidation {
// Only enable when selectively enabled targets are not being passed via cli.
// See https://github.com/Kotlin/binary-compatibility-validator/issues/269
@OptIn(kotlinx.validation.ExperimentalBCVApi::class)
klib.enabled = findProperty("KMP_TARGETS") == null

if (CHECK_PUBLICATION != null) {
ignoredProjects.add("check-publication")
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ androidx-test-core = "1.5.0"
androidx-test-runner = "1.5.2"

gradle-android = "8.2.2"
gradle-binary-compat = "0.14.0"
gradle-binary-compat = "0.16.3"
gradle-kmp-configuration = "0.3.2"
gradle-kotlin = "1.9.24"
gradle-publish-maven = "0.29.0"
Expand Down
Empty file.
4 changes: 4 additions & 0 deletions library/file-test-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ plugins {
id("configuration")
}

repositories {
google()
}

kmpConfiguration {
configure {
androidLibrary {
Expand Down
Loading
Loading