Skip to content

Commit 3188724

Browse files
committed
Improve the script for features in Kotlin 1.7.0
1 parent 33e4479 commit 3188724

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

scripts/create-new-release-notes.main.kts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,23 @@
22

33
@file:JvmName("ReleaseNotesGenerator")
44
@file:CompilerOptions("-jvm-target", "11")
5-
@file:CompilerOptions("-Xopt-in", "kotlin.RequiresOptIn")
6-
@file:OptIn(kotlin.time.ExperimentalTime::class)
75
@file:Repository("https://repo.maven.apache.org/maven2")
86
@file:Repository("https://jcenter.bintray.com")
97
@file:Repository("https://jitpack.io")
108
@file:DependsOn("com.rometools:rome:1.16.0")
119
@file:DependsOn("org.jsoup:jsoup:1.14.3")
1210

13-
// FIXME: Cannot use jsoup in scripts with Kotlin 1.6.x, for now.
14-
// See https://youtrack.jetbrains.com/issue/KT-50378
15-
1611
import com.rometools.rome.io.SyndFeedInput
1712
import com.rometools.rome.io.XmlReader
1813
import org.jsoup.Jsoup
1914
import org.jsoup.nodes.Document
2015
import org.jsoup.nodes.Element
2116
import java.io.File
2217
import java.net.URL
23-
import kotlin.time.DurationUnit
24-
import kotlin.time.toDuration
18+
import kotlin.time.Duration.Companion.seconds
2519

2620
val resultFile = File("release-notes.html")
27-
// TODO: Use Int::seconds when/if switched to Kotlin v1.6.x or higher
28-
val waitTime = 10.toDuration(DurationUnit.SECONDS)
21+
val waitTime = 10.seconds
2922
val feedUrl = URL("https://developer.android.com/feeds/androidx-release-notes.xml")
3023
val writer = resultFile.bufferedWriter()
3124
val reader = tryTo("initialize the feed reader") {
@@ -82,10 +75,10 @@ fun <T> tryTo(
8275

8376
fun toLink(element: Element) = element.attr("href")
8477

85-
// FIXME: Use plain Jsoup.connect()... and remove Pair()
78+
// FIXME: Use plain Jsoup.connect()... and remove Pair creation (to)
8679
// See https://github.com/jhy/jsoup/issues/1686 for the reason.
8780
fun toDocument(link: String) = tryTo("get $link") {
88-
Pair(link, Jsoup.connect(link).get())
81+
link to Jsoup.connect(link).get()
8982
}
9083

9184
fun toReleaseNote(pair: Pair<String, Document>): String {
@@ -133,6 +126,7 @@ fun Document.extractChangelog(id: String) = this
133126
// This is a coroutine version of the code.
134127
// Needs `org.jetbrains.kotlinx:kotlinx-coroutines-core`
135128
// which seems to not work in Kotlin scripts.
129+
// Probably fixed in Kotlin 1.7
136130
/*
137131
fun main() = runBlocking {
138132
val init = async(Dispatchers.IO) {

0 commit comments

Comments
 (0)