Skip to content

Commit 5080daf

Browse files
committed
chore: fix appendln Kotlin deprecations
1 parent ea7b132 commit 5080daf

File tree

14 files changed

+158
-37
lines changed

14 files changed

+158
-37
lines changed

plugins/checksum-dependency-plugin/src/main/kotlin/com/github/vlsi/gradle/checksum/ChecksumDependency.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,17 @@ class ChecksumDependency(
336336
append("\n")
337337
}
338338
append("Checksum/PGP violations detected on resolving configuration ")
339-
.appendln(name)
339+
.appendPlatformLine(name)
340340
violations
341341
.groupByTo(TreeMap(), { it.second }, { it.first })
342342
.forEach { (violation, artifacts) ->
343-
append(" ").append(violation).appendln(":")
343+
append(" ").append(violation).appendPlatformLine(":")
344344
artifacts
345345
.asSequence()
346346
.map { "${it.id.dependencyNotation} (pgp=${it.pgpKeys.hexKeys}, sha512=${it.sha512.ifEmpty { "[computation skipped]" }})" }
347347
.sorted()
348348
.forEach {
349-
append(" ").appendln(it)
349+
append(" ").appendPlatformLine(it)
350350
}
351351
}
352352
return this
@@ -362,7 +362,7 @@ class ChecksumDependency(
362362
sb.appendViolations(configuration, violations)
363363
}
364364
if (failOn == FailOn.FIRST_ERROR) {
365-
sb.appendln("\nThere might be more checksum violations," +
365+
sb.appendPlatformLine("\nThere might be more checksum violations," +
366366
" however, current configuration specifies the build to fail on the first violation.")
367367
sb.append("You might use the following properties:" +
368368
"\n * -PchecksumIgnore temporary disables checksum-dependency-plugin (e.g. to try new dependencies)")
@@ -371,7 +371,7 @@ class ChecksumDependency(
371371
"\n * -PchecksumUpdate updates checksum.xml and it will fail after the first violation so you can review the diff"
372372
)
373373
}
374-
sb.appendln(
374+
sb.appendPlatformLine(
375375
"\n * -PchecksumUpdateAll (insecure) updates checksum.xml with all the new discovered checksums" +
376376
"\n * -PchecksumFailOn=build_finish (insecure) It will postpone the failure till the build finish"
377377
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2019 Vladimir Sitnikov <[email protected]>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
package com.github.vlsi.gradle.checksum
18+
19+
internal fun Appendable.appendPlatformLine() =
20+
append(System.lineSeparator())
21+
22+
internal fun Appendable.appendPlatformLine(line: String) =
23+
append(line).appendPlatformLine()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2019 Vladimir Sitnikov <[email protected]>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
package com.github.vlsi.gradle
18+
19+
internal fun Appendable.appendPlatformLine() =
20+
append(System.lineSeparator())
21+
22+
internal fun Appendable.appendPlatformLine(line: String) =
23+
append(line).appendPlatformLine()

plugins/crlf-plugin/src/main/kotlin/com/github/vlsi/gradle/git/GitIgnoreFilter.kt

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package com.github.vlsi.gradle.git
1818

19+
import com.github.vlsi.gradle.appendPlatformLine
1920
import org.eclipse.jgit.attributes.Attribute
2021
import org.eclipse.jgit.attributes.Attributes
2122
import org.eclipse.jgit.attributes.AttributesHandler
@@ -81,9 +82,9 @@ class DirectorySet<E> {
8182
StringBuilder().also {
8283
for ((path, value) in files.entries) {
8384
if (it.isNotEmpty()) {
84-
it.appendln()
85+
it.appendPlatformLine()
8586
}
86-
it.append("# ").appendln(path)
87+
it.append("# ").appendPlatformLine(path)
8788
it.append(value)
8889
}
8990
}.toString()
@@ -199,11 +200,11 @@ class GitIgnoreNode(
199200

200201
private fun appendNode(sb: StringBuilder) {
201202
if (sb.isNotEmpty()) {
202-
sb.appendln()
203+
sb.appendPlatformLine()
203204
}
204205
for (rule in ignoreNode.rules) {
205206
sb.appendIgnoreRule(rule)
206-
sb.appendln()
207+
sb.appendPlatformLine()
207208
}
208209
}
209210

@@ -254,11 +255,11 @@ class GitAttributesNode(
254255

255256
private fun appendNode(sb: StringBuilder) {
256257
if (sb.isNotEmpty()) {
257-
sb.appendln()
258+
sb.appendPlatformLine()
258259
}
259260
for (rule in attributesNode.rules) {
260261
sb.appendAttributesRule(rule)
261-
sb.appendln()
262+
sb.appendPlatformLine()
262263
}
263264
}
264265

plugins/gettext-plugin/src/main/kotlin/com/github/vlsi/gradle/gettext/GettextTask.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ open class GettextTask @Inject constructor(
6565
val inputFilesList = File(project.buildDir, "gettext/$name/input_files.txt")
6666
val baseDir = project.projectDir
6767
inputFilesList.writer().buffered().use { f ->
68-
sourceFiles.files.forEach { f.appendln(it.relativeTo(baseDir).path) }
68+
sourceFiles.files.forEach {
69+
f.append(it.relativeTo(baseDir).path).append(System.lineSeparator())
70+
}
6971
}
7072

7173
val cmd = executable.get()

plugins/gradle-extensions-plugin/src/main/kotlin/com/github/vlsi/gradle/ReportBuildFailures.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object ReportBuildFailures : BuildAdapter() {
3333
gradle.rootProject.createThrowablePrinter()
3434
}
3535
throwablePrinter.indent = " "
36-
sb.appendln()
36+
sb.appendPlatformLine()
3737
sb.append(result.action).append(" ")
3838
sb.withStyle(Style.BOLD) {
3939
append(gradle?.rootProject?.name ?: "unknown rootProject")
@@ -45,7 +45,7 @@ object ReportBuildFailures : BuildAdapter() {
4545
}
4646
// Sometimes the message interferes with Gradle's progress bar.
4747
// So we print extra spaces so the garbage after "reason" is wiped out.
48-
sb.appendln(" reason: ")
48+
sb.appendPlatformLine(" reason: ")
4949
throwablePrinter.print(failure, sb)
5050
if (throwablePrinter.interestingCases > 0 || throwablePrinter.classExcludes.isEmpty()) {
5151
println(sb.toString())

plugins/gradle-extensions-plugin/src/main/kotlin/com/github/vlsi/gradle/ThrowablePrinter.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class ThrowablePrinter {
173173
if (!dejaVu.add(throwable)) {
174174
out.append(indent).append(causeTitle)
175175
val simpleName = throwable.javaClass.simpleName
176-
out.append("[CIRCULAR REFERENCE ").append(simpleName).appendln("]")
176+
out.append("[CIRCULAR REFERENCE ").append(simpleName).appendPlatformLine("]")
177177
continue
178178
}
179179

@@ -203,15 +203,15 @@ class ThrowablePrinter {
203203
}
204204
out.append(causeTitle).append(title)
205205
}
206-
out.appendln()
206+
out.appendPlatformLine()
207207
}
208208

209209
if (throwable is PlaceholderException &&
210210
throwable.exceptionClassName == "org.opentest4j.MultipleFailuresError" &&
211211
throwable.suppressed.isEmpty()
212212
) {
213213
out.append(indent)
214-
out.appendln(" ^ stacktrace is not available, see https://github.com/ota4j-team/opentest4j/issues/64")
214+
out.appendPlatformLine(" ^ stacktrace is not available, see https://github.com/ota4j-team/opentest4j/issues/64")
215215
}
216216

217217
val ourStack = if (hideStacktrace) {
@@ -282,13 +282,13 @@ class ThrowablePrinter {
282282
out.ifStyled {
283283
switchTo(style)
284284
}
285-
out.append("at ").appendln(element.toString())
285+
out.append("at ").appendPlatformLine(element.toString())
286286
out.ifStyled { switchTo(prevStyle) }
287287
}
288288
if (lastFrame != ourStack.lastIndex) {
289289
out.ifStyled { switchTo(faintStyle) }
290290
out.append(nextIndent).append("... ")
291-
out.append((ourStack.lastIndex - lastFrame).toString()).appendln(" more")
291+
out.append((ourStack.lastIndex - lastFrame).toString()).appendPlatformLine(" more")
292292
}
293293
out.ifStyled {
294294
switchTo(prevStyle)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2019 Vladimir Sitnikov <[email protected]>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
package com.github.vlsi.gradle
18+
19+
internal fun Appendable.appendPlatformLine() =
20+
append(System.lineSeparator())
21+
22+
internal fun Appendable.appendPlatformLine(line: String) =
23+
append(line).appendPlatformLine()

plugins/gradle-extensions-plugin/src/main/kotlin/com/github/vlsi/gradle/test/dsl/PrintTestResults.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package com.github.vlsi.gradle.test.dsl
1818

19+
import com.github.vlsi.gradle.appendPlatformLine
1920
import com.github.vlsi.gradle.createThrowablePrinter
2021
import com.github.vlsi.gradle.github.GitHubActionsLogger
2122
import com.github.vlsi.gradle.properties.dsl.props
@@ -112,7 +113,7 @@ fun Test.printTestResults(
112113
}
113114
if (showStacktrace) {
114115
result.exceptions.forEach {
115-
sb.appendln()
116+
sb.appendPlatformLine()
116117
throwablePrinter.print(it, sb)
117118
}
118119
}
@@ -131,7 +132,7 @@ fun Test.printTestResults(
131132
val msg = StringBuilder()
132133
msg.append(formattedDuration).append(" ").append(displayName)
133134
result.exceptions.forEach {
134-
msg.appendln()
135+
msg.appendPlatformLine()
135136
throwablePrinter.print(it, msg, baseIndent = "")
136137
}
137138
println(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2019 Vladimir Sitnikov <[email protected]>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package com.github.vlsi.gradle
19+
20+
internal fun Appendable.appendPlatformLine() =
21+
append(System.lineSeparator())
22+
23+
internal fun Appendable.appendPlatformLine(line: String) =
24+
append(line).appendPlatformLine()

plugins/license-gather-plugin/src/main/kotlin/com/github/vlsi/gradle/license/GatherLicenseTask.kt

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.github.vlsi.gradle.license
1919

20+
import com.github.vlsi.gradle.appendPlatformLine
2021
import com.github.vlsi.gradle.license.api.DependencyInfo
2122
import com.github.vlsi.gradle.license.api.JustLicense
2223
import com.github.vlsi.gradle.license.api.License
@@ -412,12 +413,12 @@ open class GatherLicenseTask @Inject constructor(
412413
val sb = StringBuilder()
413414
if (missingLicenseId.isNotEmpty()) {
414415
sb.appendTitle("LicenseID is not specified for components")
415-
missingLicenseId.map { it.displayName }.sorted().forEach { sb.appendln("* $it") }
416+
missingLicenseId.map { it.displayName }.sorted().forEach { sb.appendPlatformLine("* $it") }
416417
}
417418
if (nonModuleDependency.isNotEmpty()) {
418419
sb.appendTitle("Only ModuleComponentIdentifier are supported for now")
419420
missingLicenseId.sortedBy { it.displayName }
420-
.forEach { sb.appendln("* ${it.displayName} (${it::class.simpleName}") }
421+
.forEach { sb.appendPlatformLine("* ${it.displayName} (${it::class.simpleName}") }
421422
}
422423
if (missingLicenseFile.isNotEmpty()) {
423424
sb.appendTitle("LICENSE-like files are missing")
@@ -426,9 +427,9 @@ open class GatherLicenseTask @Inject constructor(
426427
TreeMap(nullsFirst(LicenseExpression.NATURAL_ORDER))
427428
) { allDependencies[it]?.license }
428429
.forEach { (license, ids) ->
429-
sb.appendln()
430-
sb.appendln(license ?: "Unknown license")
431-
ids.map { it.displayName }.forEach { sb.appendln("* $it") }
430+
sb.appendPlatformLine()
431+
sb.appendPlatformLine(license?.toString() ?: "Unknown license")
432+
ids.map { it.displayName }.forEach { sb.appendPlatformLine("* $it") }
432433
}
433434
}
434435
val unusedOverrides = licenseOverrides.unusedOverrides
@@ -492,8 +493,8 @@ open class GatherLicenseTask @Inject constructor(
492493
if (isNotEmpty()) {
493494
append("\n")
494495
}
495-
appendln(title)
496-
appendln("=".repeat(title.length))
496+
appendPlatformLine(title)
497+
appendPlatformLine("=".repeat(title.length))
497498
}
498499

499500
private fun findManifestLicenses(

plugins/stage-vote-release-plugin/src/main/kotlin/com/github/vlsi/gradle/release/Apache2LicenseRenderer.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ open class Apache2LicenseRenderer @Inject constructor(
106106
val license = mainLicenseFile.orNull?.asFile?.readText()
107107
?: mainLicenseText.orNull
108108
?: SpdxLicense.Apache_2_0.text
109-
out.appendln(license)
109+
out.appendPlatformLine(license)
110110

111111
if (dependencies.isNotEmpty() && dependencySubfoder.get().isNotEmpty()) {
112-
out.appendln(
112+
out.appendPlatformLine(
113113
"Additional License files can be found in the '${dependencySubfoder.get()}' folder " +
114114
"located in the same directory as the LICENSE file (i.e. this file)"
115115
)
116-
out.appendln()
116+
out.appendPlatformLine()
117117
}
118118
dependencies
119119
.map { (id, licenseInfo) ->
@@ -123,7 +123,7 @@ open class Apache2LicenseRenderer @Inject constructor(
123123
licenseGroupOf(id, license)
124124
}
125125
.forEach { (licenseGroup, components) ->
126-
out.appendln(licenseGroup.title)
126+
out.appendPlatformLine(licenseGroup.title)
127127
out.appendComponents(components)
128128

129129
if (licenseGroup != LicenseGroup.OTHER) {
@@ -155,10 +155,10 @@ open class Apache2LicenseRenderer @Inject constructor(
155155
.groupByTo(TreeMap(nullsFirst(LicenseExpression.NATURAL_ORDER)),
156156
{ it.second }, { it.first })
157157
.forEach { (license, components) ->
158-
appendln()
159-
appendln(license?.toString() ?: "Unknown license")
158+
appendPlatformLine()
159+
appendPlatformLine(license?.toString() ?: "Unknown license")
160160
components.forEach {
161-
appendln("* ${it.displayName}")
161+
appendPlatformLine("* ${it.displayName}")
162162
}
163163
}
164164

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2019 Vladimir Sitnikov <[email protected]>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
package com.github.vlsi.gradle.release
18+
19+
internal fun Appendable.appendPlatformLine() =
20+
append(System.lineSeparator())
21+
22+
internal fun Appendable.appendPlatformLine(line: String) =
23+
append(line).appendPlatformLine()

0 commit comments

Comments
 (0)