-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed support for Gradle < 7.0 (#267)
- Loading branch information
Showing
4 changed files
with
124 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/functionalTest/kotlin/kotlinx/validation/test/GradleCompatibilityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright 2016-2024 JetBrains s.r.o. | ||
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
package kotlinx.validation.test | ||
|
||
import kotlinx.validation.api.* | ||
import org.assertj.core.api.Assertions | ||
import org.gradle.testkit.runner.GradleRunner | ||
import org.junit.Assume | ||
import org.junit.Test | ||
import kotlin.test.assertTrue | ||
|
||
class GradleCompatibilityTest : BaseKotlinGradleTest() { | ||
|
||
@Test | ||
fun test8Dot0() { | ||
checkDumpWithGradle("8.0") | ||
} | ||
|
||
@Test | ||
fun test7Dot0() { | ||
checkDumpWithGradle("7.0") | ||
} | ||
|
||
@Test | ||
fun testMin() { | ||
val runner = test(gradleVersion = "6.1.1", injectPluginClasspath = false) { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPluginMinKotlin.gradle.kts") | ||
} | ||
kotlin("AnotherBuildConfig.kt") { | ||
resolve("/examples/classes/AnotherBuildConfig.kt") | ||
} | ||
|
||
runner(withConfigurationCache = false) { | ||
arguments.add(":apiDump") | ||
} | ||
} | ||
|
||
skipInDebug(runner) | ||
|
||
runner.build().apply { | ||
assertTaskSuccess(":apiDump") | ||
|
||
assertTrue(rootProjectApiDump.exists(), "api dump file should exist") | ||
|
||
val expected = readFileList("/examples/classes/AnotherBuildConfig.dump") | ||
Assertions.assertThat(rootProjectApiDump.readText()).isEqualToIgnoringNewLines(expected) | ||
} | ||
} | ||
|
||
private fun skipInDebug(runner: GradleRunner) { | ||
Assume.assumeFalse( | ||
"The test requires a separate Gradle distributive " + | ||
"so it could not be executed with debug turned on.", | ||
runner.isDebug | ||
) | ||
} | ||
|
||
private fun checkDumpWithGradle(gradleVersion: String) { | ||
val runner = test(gradleVersion = gradleVersion, injectPluginClasspath = false) { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
} | ||
kotlin("AnotherBuildConfig.kt") { | ||
resolve("/examples/classes/AnotherBuildConfig.kt") | ||
} | ||
|
||
runner { | ||
arguments.add(":apiDump") | ||
} | ||
} | ||
|
||
skipInDebug(runner) | ||
|
||
runner.build().apply { | ||
assertTaskSuccess(":apiDump") | ||
|
||
assertTrue(rootProjectApiDump.exists(), "api dump file should exist") | ||
|
||
val expected = readFileList("/examples/classes/AnotherBuildConfig.dump") | ||
Assertions.assertThat(rootProjectApiDump.readText()).isEqualToIgnoringNewLines(expected) | ||
} | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/functionalTest/resources/examples/gradle/base/withPluginMinKotlin.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright 2016-2020 JetBrains s.r.o. | ||
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
plugins { | ||
kotlin("jvm") version "1.6.20" | ||
id("org.jetbrains.kotlinx.binary-compatibility-validator") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation(kotlin("stdlib-jdk8")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters