Skip to content

Commit 3399d12

Browse files
committed
Improve Gradle functional test configuration
1 parent bc8cc4b commit 3399d12

File tree

5 files changed

+46
-31
lines changed

5 files changed

+46
-31
lines changed

build-mokkery/src/main/kotlin/mokkery-publish.gradle.kts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ dokka.dokkaSourceSets.configureEach {
2222
}
2323
}
2424

25+
publishing.repositories {
26+
maven {
27+
name = "testing"
28+
url = rootProject.layout
29+
.buildDirectory
30+
.dir("testing-repository")
31+
.let(::uri)
32+
}
33+
}
34+
2535
mavenPublishing {
2636
val isCentralPublishing = gradle.startParameter.taskNames.any { it.contains("MavenCentral") }
2737
coordinates(project.group.toString(), project.name, project.version.toString())

gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ kotlin.code.style=official
33
kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning
44
kotlin.native.ignoreDisabledTargets=true
55
org.gradle.jvmargs=-Xmx3g
6-
version=3.2.0
76
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
87
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
98
org.gradle.parallel=true
9+
version=3.2.0
10+
minimumKotlinVersion=2.3.0
11+
testKotlinVersion=2.3.0

mokkery-core-tooling/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ buildConfig {
2626
buildConfigField("String", "RUNTIME", str("mokkery-runtime"))
2727
buildConfigField("String", "PLUGIN_ID", str(rootProject.ext["pluginId"]))
2828
buildConfigField("String", "PLUGIN_ARTIFACT_ID", str(pluginProject.name))
29-
buildConfigField("String", "MINIMUM_KOTLIN_VERSION", str("2.3.0"))
29+
buildConfigField("String", "MINIMUM_KOTLIN_VERSION", str(project.property("minimumKotlinVersion")))
3030
buildConfigField("String", "COMPILED_KOTLIN_VERSION", str(libs.versions.kotlin.get()))
3131
}
3232

mokkery-gradle/build.gradle.kts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
66

77
plugins {
88
kotlin("jvm")
9+
id("com.github.gmazzo.buildconfig")
910
id("mokkery-publish")
1011
alias(libs.plugins.gradle.portal.publish)
1112
}
@@ -32,20 +33,31 @@ val functionalTest by testing.suites.creating(JvmTestSuite::class) {
3233
testTask.configure {
3334
testLogging.showStandardStreams = true
3435
mustRunAfter("test")
35-
val repoName = "MavenLocal"
36+
val repoName = "TestingRepository"
3637
dependsOnPublishMultiplatformTo(":mokkery-core", repoName)
3738
dependsOnPublishMultiplatformTo(":mokkery-runtime", repoName)
3839
dependsOnPublishMultiplatformTo(":mokkery-coroutines", repoName)
40+
dependsOnGradlePublishTo(":mokkery-gradle", repoName)
3941
dependsOnPublishTo(":mokkery-core-tooling", repoName)
4042
dependsOnPublishTo(":mokkery-plugin", repoName)
41-
dependsOnPublishTo(":mokkery-gradle", repoName)
4243
}
4344
}
4445
dependencies {
4546
implementation(gradleTestKit())
4647
}
4748
}
4849

50+
buildConfig {
51+
functionalTest.sources {
52+
packageName("${project.group}.gradle")
53+
val testingRepository = publishing.repositories
54+
.find { it.name == "testing" }
55+
.let { it as MavenArtifactRepository }
56+
buildConfigField("TESTING_REPO_URL", testingRepository.url)
57+
buildConfigField("TEST_KOTLIN_VERSION", project.property("testKotlinVersion").toString())
58+
}
59+
}
60+
4961
tasks.check { dependsOn(functionalTest) }
5062

5163
gradlePlugin {
@@ -64,7 +76,6 @@ gradlePlugin {
6476
"mock",
6577
"test",
6678
"kotlin-multiplatform",
67-
"kotlin-multiplatform-mobile",
6879
"kotlin-compiler-plugin"
6980
)
7081
)
@@ -74,7 +85,12 @@ gradlePlugin {
7485
}
7586

7687
private fun Test.dependsOnPublishTo(project: String, repoName: String) {
77-
dependsOn(project(project).tasks.named("publishTo$repoName"))
88+
dependsOn(project(project).tasks.named("publishMavenPublicationTo$repoName"))
89+
}
90+
91+
private fun Test.dependsOnGradlePublishTo(project: String, repoName: String) {
92+
dependsOn(project(project).tasks.named("publishMavenPublicationTo$repoName"))
93+
dependsOn(project(project).tasks.named("publishMokkeryPluginMarkerMavenPublicationTo$repoName"))
7894
}
7995

8096
private fun Test.dependsOnPublishMultiplatformTo(project: String, repoName: String) {

mokkery-gradle/src/functionalTest/kotlin/dev/mokkery/gradle/MokkeryGradlePluginFunctionalTest.kt

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,19 @@ import java.io.File
99
import kotlin.io.path.ExperimentalPathApi
1010
import kotlin.io.path.copyToRecursively
1111

12+
@OptIn(ExperimentalPathApi::class)
1213
class MokkeryGradlePluginFunctionalTest {
1314

1415
@field:TempDir
1516
private lateinit var testProjectDir: File
1617

1718
private val buildFile by lazy { testProjectDir.resolve("build.gradle.kts") }
1819
private val settingsFile by lazy { testProjectDir.resolve("settings.gradle.kts") }
19-
private val localPropertiesFile by lazy { testProjectDir.resolve("local.properties") }
2020

2121
@Test
22-
fun `test minimum Kotlin version`() {
23-
test(MokkeryConfig.MINIMUM_KOTLIN_VERSION)
24-
}
25-
26-
@OptIn(ExperimentalPathApi::class)
27-
private fun test(kotlinVersion: String) {
22+
fun test() {
2823
settingsFile.writeText(settingsFileContent)
2924
buildFile.writeText(buildFileContent)
30-
File("../local.properties")
31-
.takeIf { it.exists() }
32-
?.copyTo(localPropertiesFile)
33-
3425
File("../test-mokkery/src").toPath()
3526
.copyToRecursively(
3627
testProjectDir
@@ -42,7 +33,7 @@ class MokkeryGradlePluginFunctionalTest {
4233
GradleRunner.create()
4334
.withProjectDir(testProjectDir)
4435
.withArguments(
45-
"-PkotlinVersion=${kotlinVersion}",
36+
"-PkotlinVersion=${BuildConfig.TEST_KOTLIN_VERSION}",
4637
"-PmokkeryVersion=${MokkeryConfig.VERSION}",
4738
"-Porg.gradle.jvmargs=-Xmx1g",
4839
"-Pkotlin.daemon.jvmargs=-Xmx1g",
@@ -65,34 +56,30 @@ private val settingsFileContent = """
6556
id("org.jetbrains.kotlin.plugin.allopen") version kotlinVersion
6657
id("dev.mokkery") version mokkeryVersion
6758
}
68-
repositories {
69-
mavenCentral {
59+
repositories {
60+
mavenCentral {
7061
content {
7162
excludeGroup("dev.mokkery")
7263
}
7364
}
74-
google {
75-
content {
76-
excludeGroup("dev.mokkery")
77-
}
65+
maven {
66+
name = "testing"
67+
url = uri("${BuildConfig.TESTING_REPO_URL}")
7868
}
79-
mavenLocal()
8069
}
8170
}
8271
8372
dependencyResolutionManagement {
84-
repositories {
73+
repositories {
8574
mavenCentral {
8675
content {
8776
excludeGroup("dev.mokkery")
8877
}
8978
}
90-
google {
91-
content {
92-
excludeGroup("dev.mokkery")
93-
}
79+
maven {
80+
name = "testing"
81+
url = uri("${BuildConfig.TESTING_REPO_URL}")
9482
}
95-
mavenLocal()
9683
}
9784
}
9885
""".trimIndent()

0 commit comments

Comments
 (0)