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

update BCV to 0.14.0 #29

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ or (**experimentally**) [as a Settings plugin](#settings-plugin) in `settings.gr

The minimal supported Gradle version is 7.6.

By default, BCV-MU uses BCV version `0.13.2`, which can be overridden, but may introduce runtime
By default, BCV-MU uses BCV version `0.14.0`, which can be overridden, but may introduce runtime
errors.

### Build plugin
Expand Down Expand Up @@ -100,7 +100,7 @@ binaryCompatibilityValidator {
bcvEnabled.set(true)

// Override the default BCV version
kotlinxBinaryCompatibilityValidatorVersion.set("0.13.2")
kotlinxBinaryCompatibilityValidatorVersion.set("0.14.0")
}
```

Expand Down
5 changes: 1 addition & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx4g -XX:+HeapDumpOnOutOfMemoryError
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError

org.gradle.caching=true

Expand All @@ -7,6 +7,3 @@ org.gradle.unsafe.configuration-cache-problems=warn

org.gradle.parallel=true
org.gradle.welcome=never

# https://github.com/gradle/gradle/issues/9268#issuecomment-1397116301
systemProp.org.gradle.unsafe.kotlin.assignment=true
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kotlinGradle = "1.9.22"
javaDiffUtils = "4.12"
junit = "5.10.1"
kotest = "5.8.0"
kotlinx-bcv = "0.13.2"
kotlinx-bcv = "0.14.0"

gradlePluginPublishPlugin = "1.2.1"
shadowPlugin = "8.1.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kotlinx.validation.test

import dev.adamko.kotlin.binary_compatibility_validator.test.*
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.*
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.api.*
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.build
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.shouldHaveRunTask
import java.io.File
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
import org.junit.jupiter.api.Disabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,35 @@ internal class IgnoredClassesTests : BaseKotlinGradleTest() {

val expected = readResourceFile("/examples/classes/AnotherBuildConfig.dump")
rootProjectApiDump.readText().shouldBeEqualComparingTo(expected)
// Assertions.assertThat(rootProjectApiDump.readText()).isEqualToIgnoringNewLines(expected)
}
}

@Test
fun `apiDump should dump class whose name is a subsset of another class that is excluded via ignoredClasses`() {
val runner = test {
buildGradleKts {
resolve("/examples/gradle/base/withPlugin.gradle.kts")
resolve("/examples/gradle/configuration/ignoredClasses/oneValidFullyQualifiedClass.gradle.kts")
}
kotlin("BuildConfig.kt") {
resolve("/examples/classes/BuildConfig.kt")
}
kotlin("BuildCon.kt") {
resolve("/examples/classes/BuildCon.kt")
}

runner {
arguments.add(":apiDump")
}
}

runner.build().apply {
shouldHaveRunTask(":apiDump", SUCCESS)

assertTrue(rootProjectApiDump.exists(), "api dump file should exist")

val expected = readResourceFile("/examples/classes/BuildCon.dump")
rootProjectApiDump.readText().shouldBeEqualComparingTo(expected)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package kotlinx.validation.test
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.api.*
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.build
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.shouldHaveTaskWithOutcome
import io.kotest.matchers.file.shouldExist
import io.kotest.matchers.shouldBe
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
import org.junit.jupiter.api.Test

Expand Down Expand Up @@ -33,4 +35,40 @@ class NonPublicMarkersTest : BaseKotlinGradleTest() {
shouldHaveTaskWithOutcome(":apiCheck", SUCCESS)
}
}

@Test
fun testFiltrationByPackageLevelAnnotations() {
val runner = test {
buildGradleKts {
resolve("/examples/gradle/base/withPlugin.gradle.kts")
resolve("/examples/gradle/configuration/nonPublicMarkers/packages.gradle.kts")
}
java("annotated/PackageAnnotation.java") {
resolve("/examples/classes/PackageAnnotation.java")
}
java("annotated/package-info.java") {
resolve("/examples/classes/package-info.java")
}
kotlin("ClassFromAnnotatedPackage.kt") {
resolve("/examples/classes/ClassFromAnnotatedPackage.kt")
}
kotlin("AnotherBuildConfig.kt") {
resolve("/examples/classes/AnotherBuildConfig.kt")
}
runner {
arguments.add(":apiDump")
}
}

runner
.forwardOutput()
.build {
shouldHaveTaskWithOutcome(":apiDump", SUCCESS)

rootProjectApiDump.shouldExist()

val dumpFile = readResourceFile("/examples/classes/AnotherBuildConfig.dump")
rootProjectApiDump.readText() shouldBe dumpFile
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
package kotlinx.validation.test

import dev.adamko.kotlin.binary_compatibility_validator.test.utils.api.*
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.build
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.buildAndFail
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.shouldHaveTaskWithOutcome
import io.kotest.assertions.withClue
import io.kotest.matchers.file.shouldExist
import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldContain
import org.gradle.testkit.runner.TaskOutcome.FAILED
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
import org.junit.jupiter.api.Test

class OutputDirectoryTests : BaseKotlinGradleTest() {

@Test
fun dumpIntoCustomDirectory() {
val runner = test {
buildGradleKts {
resolve("/examples/gradle/base/withPlugin.gradle.kts")
resolve("/examples/gradle/configuration/outputDirectory/different.gradle.kts")
}

kotlin("AnotherBuildConfig.kt") {
resolve("/examples/classes/AnotherBuildConfig.kt")
}
dir("api") {
file("letMeBe.txt")
}

runner {
arguments.add(":apiDump")
}
}

runner.build {
shouldHaveTaskWithOutcome(":apiDump", SUCCESS)

val dumpFile = rootProjectDir.resolve("custom/${rootProjectDir.name}.api")
dumpFile.shouldExist()

val expected = readResourceFile("/examples/classes/AnotherBuildConfig.dump")
dumpFile.readText() shouldBe expected

val fileInsideDir = rootProjectDir.resolve("api").resolve("letMeBe.txt")
withClue("existing api directory should not be overwritten") {
fileInsideDir.shouldExist()
}
}
}

@Test
fun validateDumpFromACustomDirectory() {
val runner = test {
buildGradleKts {
resolve("/examples/gradle/base/withPlugin.gradle.kts")
resolve("/examples/gradle/configuration/outputDirectory/different.gradle.kts")
}

kotlin("AnotherBuildConfig.kt") {
resolve("/examples/classes/AnotherBuildConfig.kt")
}
dir("custom") {
file("${rootProjectDir.name}.api") {
resolve("/examples/classes/AnotherBuildConfig.dump")
}
}

runner {
arguments.add(":apiCheck")
}
}

runner.build {
shouldHaveTaskWithOutcome(":apiCheck", SUCCESS)
}
}

@Test
fun dumpIntoSubdirectory() {
val runner = test {
buildGradleKts {
resolve("/examples/gradle/base/withPlugin.gradle.kts")
resolve("/examples/gradle/configuration/outputDirectory/subdirectory.gradle.kts")
}

kotlin("AnotherBuildConfig.kt") {
resolve("/examples/classes/AnotherBuildConfig.kt")
}

runner {
arguments.add(":apiDump")
}
}

runner.build {
shouldHaveTaskWithOutcome(":apiDump", SUCCESS)

val dumpFile = rootProjectDir.resolve("validation/api/${rootProjectDir.name}.api")
dumpFile.shouldExist()

val expected = readResourceFile("/examples/classes/AnotherBuildConfig.dump")
dumpFile.readText() shouldBe expected
}
}

@Test
fun validateDumpFromASubdirectory() {
val runner = test {
buildGradleKts {
resolve("/examples/gradle/base/withPlugin.gradle.kts")
resolve("/examples/gradle/configuration/outputDirectory/subdirectory.gradle.kts")
}

kotlin("AnotherBuildConfig.kt") {
resolve("/examples/classes/AnotherBuildConfig.kt")
}
dir("validation") {
dir("api") {
file("${rootProjectDir.name}.api") {
resolve("/examples/classes/AnotherBuildConfig.dump")
}
}
}

runner {
arguments.add(":apiCheck")
}
}

runner.build {
shouldHaveTaskWithOutcome(":apiCheck", SUCCESS)
}
}

@Test
fun dumpIntoParentDirectory() {
val runner = test {
buildGradleKts {
resolve("/examples/gradle/base/withPlugin.gradle.kts")
resolve("/examples/gradle/configuration/outputDirectory/outer.gradle.kts")
}

kotlin("AnotherBuildConfig.kt") {
resolve("/examples/classes/AnotherBuildConfig.kt")
}

runner {
arguments.add(":apiDump")
}
}

runner.buildAndFail {
shouldHaveTaskWithOutcome(":apiDump", FAILED)

output shouldContain /* language=text */ """
|> Error: Invalid output apiDirectory
|
| apiDirectory is set to a custom directory, outside of the current project directory.
| This is not permitted. apiDirectory must be a subdirectory of project ':' (the root project) directory.
|
| Remove the custom apiDirectory, or update apiDirectory to be a project subdirectory.
""".trimMargin()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import dev.adamko.kotlin.binary_compatibility_validator.test.utils.api.*
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.build
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.invariantNewlines
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.shouldHaveTaskWithOutcome
import io.kotest.matchers.file.shouldBeAFile
import io.kotest.matchers.file.shouldExist
import io.kotest.matchers.shouldBe
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
import org.junit.jupiter.api.Test

Expand All @@ -15,19 +19,15 @@
resolve("/examples/gradle/base/withPlugin.gradle.kts")
resolve("/examples/gradle/configuration/publicMarkers/markers.gradle.kts")
}

kotlin("ClassWithPublicMarkers.kt") {
resolve("/examples/classes/ClassWithPublicMarkers.kt")
}

kotlin("ClassInPublicPackage.kt") {
resolve("/examples/classes/ClassInPublicPackage.kt")
}

apiFile(projectName = rootProjectDir.name) {
resolve("/examples/classes/ClassWithPublicMarkers.dump")
}

runner {
arguments.add(":apiCheck")
}
Expand All @@ -37,4 +37,38 @@
shouldHaveTaskWithOutcome(":apiCheck", SUCCESS)
}
}

@Test
fun testFiltrationByPackageLevelAnnotations() {
val runner = test {
buildGradleKts {
resolve("/examples/gradle/base/withPlugin.gradle.kts")
resolve("/examples/gradle/configuration/publicMarkers/packages.gradle.kts")
}
java("annotated/PackageAnnotation.java") {
resolve("/examples/classes/PackageAnnotation.java")
}
java("annotated/package-info.java") {
resolve("/examples/classes/package-info.java")
}
kotlin("ClassFromAnnotatedPackage.kt") {
resolve("/examples/classes/ClassFromAnnotatedPackage.kt")
}
kotlin("AnotherBuildConfig.kt") {
resolve("/examples/classes/AnotherBuildConfig.kt")
}
runner {
arguments.add(":apiDump")
}
}

runner.build {
shouldHaveTaskWithOutcome(":apiDump", SUCCESS)

rootProjectApiDump.shouldExist()
rootProjectApiDump.shouldBeAFile()
val expected = readResourceFile("/examples/classes/AnnotatedPackage.dump")
rootProjectApiDump.readText().invariantNewlines() shouldBe expected
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public final class annotated/ClassFromAnnotatedPackage {
public fun <init> ()V
}

public abstract interface annotation class annotated/PackageAnnotation : java/lang/annotation/Annotation {
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public final class com/company/BuildCon {
public fun <init> ()V
public final fun f1 ()I
public final fun getP1 ()I
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.company

public class BuildCon {
public val p1 = 1

public fun f1() = p1
}
Loading
Loading