Skip to content

Commit b306681

Browse files
committed
chore: build-logic refactorings
1 parent c9d2597 commit b306681

File tree

10 files changed

+300
-297
lines changed

10 files changed

+300
-297
lines changed

gradle/build-logic/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ dependencies {
177177
implementation(libs.jib.nativeimage.extn)
178178
implementation(libs.zip.prefixer)
179179
implementation(libs.kmpmt)
180+
implementation(libs.bytesize)
180181
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
181182
testImplementation(gradleTestKit())
182183
// compileOnly(libs.jte.kotlin)

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

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ package common
22

33
import java.io.File
44
import java.lang.reflect.Proxy
5-
import java.nio.file.FileSystems
6-
import java.nio.file.Files
7-
import java.nio.file.Path
8-
import java.text.DecimalFormat
9-
import java.text.NumberFormat
10-
import kotlin.math.ln
11-
import kotlin.math.pow
5+
import java.nio.file.*
6+
import java.text.*
7+
import kotlin.math.*
128
import kotlin.properties.ReadOnlyProperty
139
import kotlin.reflect.full.isSubtypeOf
1410
import kotlin.reflect.typeOf
@@ -52,10 +48,6 @@ inline fun <reified T> mock() =
5248
// InvocationHandler.invokeDefault(proxy, method, args)
5349
} as T
5450

55-
/** Returns the file size in a human-readable format. */
56-
val File.displaySize
57-
get() = length().byteDisplaySize()
58-
5951
val Long.compactFmt: String
6052
get() = NumberFormat.getCompactNumberInstance().format(this)
6153

@@ -73,7 +65,7 @@ val String.camelCase: String
7365
* - [SI](https://en.wikipedia.org/wiki/International_System_of_Units#Prefixes)
7466
* - [Binary](https://en.wikipedia.org/wiki/Binary_prefix)
7567
*/
76-
fun Long.byteDisplaySize(si: Boolean = true): String {
68+
private fun Long.byteDisplaySize(si: Boolean = true): String {
7769
require(this >= 0) { "Bytes can't be negative" }
7870
val unit = if (si) 1000 else 1024
7971
return when (this < unit) {
@@ -98,11 +90,8 @@ fun IntArray.codePointsToString(separator: String = "") =
9890
joinToString(separator) { Character.toString(it) }
9991

10092
/** Find the file ends with given [format] under the directory. */
101-
fun File.findPkg(format: String?) =
102-
when (format != null) {
103-
true -> walk().firstOrNull { it.isFile && it.name.endsWith(format, ignoreCase = true) }
104-
else -> null
105-
}
93+
fun File.findPkg(format: String) =
94+
walk().firstOrNull { it.isFile && it.name.endsWith(format, ignoreCase = true) }
10695

10796
/** List files based on the glob [pattern] */
10897
fun Path.glob(pattern: String): List<Path> {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fun KotlinMultiplatformExtension.jvmTarget(project: Project) =
9090

9191
mainRun {
9292
mainClass = libs.versions.app.mainclass
93-
setArgs(jvmRunArgs)
93+
setArgs(runJvmArgs)
9494
}
9595

9696
// val test by testRuns.existing
@@ -101,7 +101,7 @@ fun KotlinMultiplatformExtension.jvmTarget(project: Project) =
101101
binaries {
102102
executable {
103103
mainClass = libs.versions.app.mainclass
104-
applicationDefaultJvmArgs = jvmRunArgs
104+
applicationDefaultJvmArgs = runJvmArgs
105105
applicationDistribution.duplicatesStrategy = DuplicatesStrategy.INCLUDE
106106
}
107107
}

0 commit comments

Comments
 (0)