|
2 | 2 |
|
3 | 3 | @file:JvmName("ReleaseNotesGenerator") |
4 | 4 | @file:CompilerOptions("-jvm-target", "11") |
5 | | -@file:CompilerOptions("-Xopt-in", "kotlin.RequiresOptIn") |
6 | | -@file:OptIn(kotlin.time.ExperimentalTime::class) |
7 | 5 | @file:Repository("https://repo.maven.apache.org/maven2") |
8 | 6 | @file:Repository("https://jcenter.bintray.com") |
9 | 7 | @file:Repository("https://jitpack.io") |
10 | 8 | @file:DependsOn("com.rometools:rome:1.16.0") |
11 | 9 | @file:DependsOn("org.jsoup:jsoup:1.14.3") |
12 | 10 |
|
13 | | -// FIXME: Cannot use jsoup in scripts with Kotlin 1.6.x, for now. |
14 | | -// See https://youtrack.jetbrains.com/issue/KT-50378 |
15 | | - |
16 | 11 | import com.rometools.rome.io.SyndFeedInput |
17 | 12 | import com.rometools.rome.io.XmlReader |
18 | 13 | import org.jsoup.Jsoup |
19 | 14 | import org.jsoup.nodes.Document |
20 | 15 | import org.jsoup.nodes.Element |
21 | 16 | import java.io.File |
22 | 17 | import java.net.URL |
23 | | -import kotlin.time.DurationUnit |
24 | | -import kotlin.time.toDuration |
| 18 | +import kotlin.time.Duration.Companion.seconds |
25 | 19 |
|
26 | 20 | 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 |
29 | 22 | val feedUrl = URL("https://developer.android.com/feeds/androidx-release-notes.xml") |
30 | 23 | val writer = resultFile.bufferedWriter() |
31 | 24 | val reader = tryTo("initialize the feed reader") { |
@@ -82,10 +75,10 @@ fun <T> tryTo( |
82 | 75 |
|
83 | 76 | fun toLink(element: Element) = element.attr("href") |
84 | 77 |
|
85 | | -// FIXME: Use plain Jsoup.connect()... and remove Pair() |
| 78 | +// FIXME: Use plain Jsoup.connect()... and remove Pair creation (to) |
86 | 79 | // See https://github.com/jhy/jsoup/issues/1686 for the reason. |
87 | 80 | fun toDocument(link: String) = tryTo("get $link") { |
88 | | - Pair(link, Jsoup.connect(link).get()) |
| 81 | + link to Jsoup.connect(link).get() |
89 | 82 | } |
90 | 83 |
|
91 | 84 | fun toReleaseNote(pair: Pair<String, Document>): String { |
@@ -133,6 +126,7 @@ fun Document.extractChangelog(id: String) = this |
133 | 126 | // This is a coroutine version of the code. |
134 | 127 | // Needs `org.jetbrains.kotlinx:kotlinx-coroutines-core` |
135 | 128 | // which seems to not work in Kotlin scripts. |
| 129 | +// Probably fixed in Kotlin 1.7 |
136 | 130 | /* |
137 | 131 | fun main() = runBlocking { |
138 | 132 | val init = async(Dispatchers.IO) { |
|
0 commit comments