Skip to content

Commit a5a01a0

Browse files
committed
chore: remove context receiver
1 parent de95f4b commit a5a01a0

File tree

2 files changed

+28
-42
lines changed

2 files changed

+28
-42
lines changed

gradle/build-logic/src/main/kotlin/common/Multiplatform.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,7 @@ fun KotlinMultiplatformExtension.allNativeTargets(configure: KotlinNativeTarget.
267267
macosArm64 { configure() }
268268
linuxX64 { configure() }
269269
linuxArm64 { configure() }
270-
271-
val nativeWinTarget: String? by project
272-
if (nativeWinTarget.toBoolean()) {
273-
mingwX64 { configure() }
274-
}
270+
mingwX64 { configure() }
275271
}
276272
}
277273

gradle/build-logic/src/main/kotlin/common/ProjectExtns.kt

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ val Project.mavenCentralUsername
135135
val Project.mavenCentralPassword
136136
get() = providers.gradleProperty("mavenCentralPassword")
137137

138-
val Project.githubActor
139-
get() = providers.gradleProperty("githubActor")
138+
val Project.githubPackagesUsername
139+
get() = providers.gradleProperty("githubPackagesUsername")
140140

141-
val Project.githubToken
142-
get() = providers.gradleProperty("githubToken")
141+
val Project.githubPackagesPassword
142+
get() = providers.gradleProperty("githubPackagesPassword")
143143

144144
/** Kotlin Dependencies extension functions. */
145145
val Project.isKotlinMultiplatformProject
@@ -193,7 +193,6 @@ fun Project.jvmArguments(appRun: Boolean = false, headless: Boolean = true) = bu
193193
"-XX:+PrintCommandLineFlags",
194194
"--enable-native-access=ALL-UNNAMED",
195195
"--illegal-native-access=warn",
196-
"-Xms64M",
197196
"-Xmx128M",
198197
"-XX:+UseZGC",
199198
"-XX:+UseStringDeduplication",
@@ -407,7 +406,6 @@ fun KotlinCommonCompilerOptions.configureKotlinCommon() {
407406
suppressWarnings = false
408407
verbose = false
409408
freeCompilerArgs.addAll(
410-
"-Xcontext-receivers",
411409
"-Xexpect-actual-classes",
412410
"-Xskip-prerelease-check",
413411
// "-XXLanguage:+ExplicitBackingFields",
@@ -466,7 +464,6 @@ fun KotlinJvmCompilerOptions.configureKotlinJvm() {
466464
"-Xjsr305=strict",
467465
"-Xjvm-default=all",
468466
"-Xassertions=jvm",
469-
"-Xcontext-receivers",
470467
"-Xemit-jvm-type-annotations",
471468
"-Xjspecify-annotations=strict",
472469
"-Xextended-compiler-checks",
@@ -486,7 +483,6 @@ fun KotlinJvmCompilerOptions.configureKotlinJvm() {
486483
)
487484
}
488485

489-
context(Project)
490486
fun KotlinNativeCompilerOptions.configureKotlinNative() {
491487
freeCompilerArgs.addAll(
492488
// "-Xverbose-phases=Linker"
@@ -562,18 +558,15 @@ fun TestLoggingContainer.configureLogEvents() {
562558
}
563559
}
564560

565-
context(Project)
566561
fun KotlinTestReport.configureTestReport() {}
567562

568-
context(Project)
569563
fun KotlinJsCompilerOptions.configureKotlinJs() {
570564
// freeCompilerArgs.addAll("-Xir-per-file")
571565
// target = "es2015"
572566
// sourceMap = true
573567
// sourceMapEmbedSources = "always"
574568
}
575569

576-
context(Project)
577570
fun KotlinNpmInstallTask.configureKotlinNpm() {
578571
args.add("--ignore-engines")
579572
}
@@ -583,7 +576,6 @@ fun KotlinNpmInstallTask.configureKotlinNpm() {
583576
*
584577
* @param dependencyNotation The notation of the dependency to add.
585578
*/
586-
context(Project)
587579
fun KotlinSourceSet.ksp(dependencyNotation: Any) {
588580
val kspConfiguration =
589581
when {
@@ -594,27 +586,24 @@ fun KotlinSourceSet.ksp(dependencyNotation: Any) {
594586
name.endsWith("Main") -> name.substringBeforeLast("Main")
595587
else -> name
596588
}.replaceFirstChar { it.uppercaseChar() }
597-
dependencies.add("ksp$kspConfiguration", dependencyNotation)
589+
project.dependencies.add("ksp$kspConfiguration", dependencyNotation)
598590
}
599591

600-
/** Returns the path of the dependency jar in runtime classpath. */
601-
context(Project)
602-
val ExternalDependency.dependencyPath: Provider<String>
603-
get() = provider {
604-
configurations
605-
.named("runtimeClasspath")
606-
.get()
607-
.resolvedConfiguration
608-
.resolvedArtifacts
609-
.find { it.moduleVersion.id.module == module }
610-
?.file
611-
?.path
612-
}
592+
/** Returns the path of dependency jar in the runtime classpath. */
593+
fun Project.depPathOf(dep: ExternalDependency) = provider {
594+
configurations
595+
.named("runtimeClasspath")
596+
.get()
597+
.resolvedConfiguration
598+
.resolvedArtifacts
599+
.find { it.moduleVersion.id.module == dep.module }
600+
?.file
601+
?.path
602+
}
613603

614604
/** Returns the application `run` command. */
615-
context(Project)
616-
fun Path.appRunCmd(args: List<String>): String {
617-
val path = layout.projectDirectory.asFile.toPath().relativize(this)
605+
fun Project.appRunCmd(binary: Path, args: List<String>): String {
606+
val path = layout.projectDirectory.asFile.toPath().relativize(binary)
618607
val newLine = System.lineSeparator()
619608
val lineCont = """\""" // Bash line continuation
620609
val indent = "\t"
@@ -655,14 +644,15 @@ val Project.incubatorModules
655644
get(): String {
656645
val javaCmd = project.javaToolchainPath.resolve("bin").resolve("java")
657646
val bos = ByteArrayOutputStream()
658-
val execResult = exec {
659-
workingDir = layout.buildDirectory.get().asFile
660-
commandLine = listOf(javaCmd.toString())
661-
args = listOf("--list-modules")
662-
standardOutput = bos
663-
errorOutput = bos
664-
}
665-
execResult.assertNormalExitValue()
647+
val execResult =
648+
providers.exec {
649+
workingDir = layout.buildDirectory.get().asFile
650+
commandLine = listOf(javaCmd.toString())
651+
args = listOf("--list-modules")
652+
standardOutput = bos
653+
errorOutput = bos
654+
}
655+
execResult.result.get().assertNormalExitValue()
666656
return bos.toString(Charsets.UTF_8)
667657
.lines()
668658
.filter { it.startsWith("jdk.incubator") }

0 commit comments

Comments
 (0)