Skip to content

Commit 05d60ee

Browse files
committed
format: code formatting changes
1 parent 9fafb70 commit 05d60ee

File tree

2 files changed

+96
-94
lines changed

2 files changed

+96
-94
lines changed

buildSrc/src/Config.kt

Lines changed: 94 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,52 @@ val logger = LoggerFactory.getLogger("buildSrc")
1515
* Maven and gradle repositories.
1616
*/
1717
sealed class Repo(val name: String, val url: String) {
18-
object Central : Repo(
19-
name = "Maven Central",
20-
url = "https://repo1.maven.org/maven2/"
21-
)
22-
23-
object OssrhSnapshots : Repo(
24-
name = "Sonatype OSSRH Snapshots",
25-
url = "https://oss.sonatype.org/content/repositories/snapshots/"
26-
)
27-
28-
object OssrhStaging : Repo(
29-
name = "Sonatype OSSRH Staging",
30-
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
31-
)
32-
33-
object OssrhReleases : Repo(
34-
name = "Sonatype OSSRH Releases",
35-
url = "https://oss.sonatype.org/content/repositories/releases/"
36-
)
37-
38-
object OssrhPublic : Repo(
39-
name = "Sonatype OSSRH Public",
40-
url = "https://oss.sonatype.org/content/groups/public/"
41-
)
42-
43-
object GradlePlugins : Repo(
44-
name = "Gradle Plugin",
45-
url = "https://plugins.gradle.org/m2/"
46-
)
47-
48-
object Jetbrains : Repo(
49-
name = "Jetbrains Dev",
50-
url = "https://packages.jetbrains.team/maven/p/ui/dev"
51-
)
18+
object Central : Repo(
19+
name = "Maven Central",
20+
url = "https://repo1.maven.org/maven2/"
21+
)
22+
23+
object OssrhSnapshots : Repo(
24+
name = "Sonatype OSSRH Snapshots",
25+
url = "https://oss.sonatype.org/content/repositories/snapshots/"
26+
)
27+
28+
object OssrhStaging : Repo(
29+
name = "Sonatype OSSRH Staging",
30+
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
31+
)
32+
33+
object OssrhReleases : Repo(
34+
name = "Sonatype OSSRH Releases",
35+
url = "https://oss.sonatype.org/content/repositories/releases/"
36+
)
37+
38+
object OssrhPublic : Repo(
39+
name = "Sonatype OSSRH Public",
40+
url = "https://oss.sonatype.org/content/groups/public/"
41+
)
42+
43+
object GradlePlugins : Repo(
44+
name = "Gradle Plugin",
45+
url = "https://plugins.gradle.org/m2/"
46+
)
47+
48+
object Jetbrains : Repo(
49+
name = "Jetbrains Dev",
50+
url = "https://packages.jetbrains.team/maven/p/ui/dev"
51+
)
5252
}
5353

5454
/**
5555
* Check if it's a non stable (RC) version.
5656
*/
5757
val String.isNonStable: Boolean
58-
get() {
59-
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { toUpperCase().contains(it) }
60-
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
61-
val isStable = stableKeyword || regex.matches(this)
62-
return isStable.not()
63-
}
58+
get() {
59+
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { toUpperCase().contains(it) }
60+
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
61+
val isStable = stableKeyword || regex.matches(this)
62+
return isStable.not()
63+
}
6464

6565
/**
6666
* Checks if the project has snapshot version.
@@ -71,87 +71,89 @@ fun Project.hasSnapshotVersion() = version.toString().endsWith("SNAPSHOT", true)
7171
* Returns the JDK install path provided by the [JavaToolchainService]
7272
*/
7373
val Project.javaToolchainPath
74-
get(): String {
75-
val javaToolchains = extensions.getByName("javaToolchains") as JavaToolchainService
76-
return javaToolchains.launcherFor {
77-
languageVersion.set(JavaLanguageVersion.of(javaVersion))
78-
}.orNull
79-
?.metadata
80-
?.installationPath?.toString()
81-
?: error("Requested JDK version ($javaVersion) is not available.")
82-
}
74+
get(): String {
75+
val javaToolchains = extensions.getByName("javaToolchains") as JavaToolchainService
76+
return javaToolchains.launcherFor {
77+
languageVersion.set(JavaLanguageVersion.of(javaVersion))
78+
}.orNull
79+
?.metadata
80+
?.installationPath?.toString()
81+
?: error("Requested JDK version ($javaVersion) is not available.")
82+
}
8383

8484
/**
8585
* Returns the application `run` command.
8686
*/
8787
fun Project.appRunCmd(jarPath: Path, args: List<String>): String {
88-
val path = projectDir.toPath().relativize(jarPath)
89-
val newLine = System.lineSeparator()
90-
val lineCont = """\""" // Bash line continuation
91-
val indent = "\t"
92-
println()
93-
return args.joinToString(
94-
prefix = """
95-
To Run the app,
88+
val path = projectDir.toPath().relativize(jarPath)
89+
val newLine = System.lineSeparator()
90+
val lineCont = """\""" // Bash line continuation
91+
val indent = "\t"
92+
println()
93+
return args.joinToString(
94+
prefix = """
95+
To Run the app,
9696
${'$'} java -jar $lineCont $newLine
9797
""".trimIndent(),
98-
postfix = "$newLine$indent$path",
99-
separator = newLine,
100-
) {
101-
// Escape the globstar
102-
"$indent$it $lineCont".replace("*", """\*""")
103-
}
98+
postfix = "$newLine$indent$path",
99+
separator = newLine,
100+
) {
101+
// Escape the globstar
102+
"$indent$it $lineCont"
103+
.replace("*", """\*""")
104+
.replace("\"", "\\\"")
105+
}
104106
}
105107

106108
/**
107109
* Returns the current OS name.
108110
*/
109111
val os by lazy {
110-
val os = System.getProperty("os.name")
111-
when {
112-
os.equals("Mac OS X", ignoreCase = true) -> "macos"
113-
os.startsWith("Win", ignoreCase = true) -> "windows"
114-
os.startsWith("Linux", ignoreCase = true) -> "linux"
115-
else -> error("Unsupported OS: $os")
116-
}
112+
val os = System.getProperty("os.name")
113+
when {
114+
os.equals("Mac OS X", ignoreCase = true) -> "macos"
115+
os.startsWith("Win", ignoreCase = true) -> "windows"
116+
os.startsWith("Linux", ignoreCase = true) -> "linux"
117+
else -> error("Unsupported OS: $os")
118+
}
117119
}
118120

119121
/**
120122
* System property delegate
121123
*/
122124
@Suppress("IMPLICIT_CAST_TO_ANY")
123125
inline fun <reified T> sysProp(): ReadOnlyProperty<Any?, T> =
124-
ReadOnlyProperty { _, property ->
125-
val propVal = System.getProperty(property.name, "")
126-
val propVals = propVal.split(",", " ").filter { it.isNotBlank() }
127-
128-
val kType = typeOf<T>()
129-
when (kType) {
130-
typeOf<String>() -> propVal
131-
typeOf<Int>() -> propVal.toInt()
132-
typeOf<Boolean>() -> propVal.toBoolean()
133-
typeOf<Long>() -> propVal.toLong()
134-
typeOf<Double>() -> propVal.toDouble()
135-
typeOf<List<String>>() -> propVals
136-
typeOf<List<Int>>() -> propVals.map { it.toInt() }
137-
typeOf<List<Long>>() -> propVals.map { it.toLong() }
138-
typeOf<List<Double>>() -> propVals.map { it.toDouble() }
139-
typeOf<List<Boolean>>() -> propVals.map { it.toBoolean() }
140-
else -> error("'${property.name}' system property type ($kType) is not supported!")
141-
} as T
142-
}
126+
ReadOnlyProperty { _, property ->
127+
val propVal = System.getProperty(property.name, "")
128+
val propVals = propVal.split(",", " ").filter { it.isNotBlank() }
129+
130+
val kType = typeOf<T>()
131+
when (kType) {
132+
typeOf<String>() -> propVal
133+
typeOf<Int>() -> propVal.toInt()
134+
typeOf<Boolean>() -> propVal.toBoolean()
135+
typeOf<Long>() -> propVal.toLong()
136+
typeOf<Double>() -> propVal.toDouble()
137+
typeOf<List<String>>() -> propVals
138+
typeOf<List<Int>>() -> propVals.map { it.toInt() }
139+
typeOf<List<Long>>() -> propVals.map { it.toLong() }
140+
typeOf<List<Double>>() -> propVals.map { it.toDouble() }
141+
typeOf<List<Boolean>>() -> propVals.map { it.toBoolean() }
142+
else -> error("'${property.name}' system property type ($kType) is not supported!")
143+
} as T
144+
}
143145

144146
/**
145147
* Find the file ends with given [format] under the directory.
146148
*/
147149
fun File.findPkg(format: String?) = when (format != null) {
148-
true -> walk().firstOrNull { it.isFile && it.name.endsWith(format, ignoreCase = true) }
149-
else -> null
150+
true -> walk().firstOrNull { it.isFile && it.name.endsWith(format, ignoreCase = true) }
151+
else -> null
150152
}
151153

152154
/**
153155
* Add a Github action output if it's running on an Action runner.
154156
*/
155157
fun ghActionOutput(name: String, value: Any) {
156-
if (System.getenv("GITHUB_ACTIONS").toBoolean()) println("::set-output name=$name::$value")
158+
if (System.getenv("GITHUB_ACTIONS").toBoolean()) println("::set-output name=$name::$value")
157159
}

buildSrc/src/main/kotlin/plugins/common.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package plugins
22

3+
import org.gradle.jvm.tasks.Jar
4+
import org.gradle.tooling.*
35
import java.io.*
46
import java.util.concurrent.*
57
import java.util.spi.*
6-
import org.gradle.jvm.tasks.Jar
7-
import org.gradle.tooling.*
88

99
plugins {
1010
java

0 commit comments

Comments
 (0)