55@file:Repository(" https://repo.maven.apache.org/maven2" )
66@file:Repository(" https://jcenter.bintray.com" )
77@file:Repository(" https://jitpack.io" )
8- @file:DependsOn(" com.rometools:rome:1.16 .0" )
8+ @file:DependsOn(" com.rometools:rome:2.1 .0" )
99
1010// NOTE: See https://youtrack.jetbrains.com/issue/KT-42101
11+ // NOTE that currently, IntelliJ code features break when importing external scripts.
1112@file:Import(" retry.main.kts" )
1213
1314import com.rometools.rome.io.SyndFeedInput
1415import com.rometools.rome.io.XmlReader
15- import java.io.File
16- import java.net.URL
16+ import java.net.URI
1717import java.time.LocalDateTime
1818import java.time.format.DateTimeFormatter
19- import java.time.format.DateTimeFormatter.ISO_LOCAL_TIME
19+ import kotlin.io.path.Path
20+ import kotlin.io.path.appendText
21+ import kotlin.io.path.readText
2022
2123val datesPattern = DateTimeFormatter .ofPattern(" EEE LLL dd HH:mm:ss z yyyy" )
22- val feedUrl = URL (" https://developer.android.com/feeds/androidx-release-notes.xml" )
24+ val feedUrl = URI (" https://developer.android.com/feeds/androidx-release-notes.xml" ).toURL( )
2325val reader = tryTo(" initialize the feed reader" ) { XmlReader (feedUrl) }
24- val file = File (" last-rss-update.txt" )
26+ val file = Path (" last-rss-update.txt" )
2527val feed = SyndFeedInput ().build(reader)
26- val ours = file.readText().trimEnd().parse ()
28+ val ours = file.readText().trimEnd().parseAsLocalDateTime ()
2729val ourDate = ours.toLocalDate().toString()
28- val theirs = feed.publishedDate.toString().parse ()
30+ val theirs = feed.publishedDate.toString().parseAsLocalDateTime ()
2931val theirDate = theirs.toLocalDate().toString()
3032val theirTime = theirs.toLocalTime().format(DateTimeFormatter .ofPattern(" hha" ))
3133val areTheSame = ours == theirs
@@ -43,10 +45,11 @@ println("Their RSS publish date: $theirs")
4345// To set output for a job step
4446// see https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-output-parameter
4547// and https://stackoverflow.com/a/59201610
46- val stepsOutputFile = File (System .getenv(" GITHUB_OUTPUT" ))
48+ val stepsOutputFile = Path (System .getenv(" GITHUB_OUTPUT" ))
4749val lineFeed: String = System .lineSeparator()
4850stepsOutputFile.appendText(" result=$freshness$lineFeed " )
4951stepsOutputFile.appendText(" dateTag=$dateTag$lineFeed " )
5052
51- fun String.parse () = runCatching { LocalDateTime .parse(this , datesPattern) }
53+ fun String.parseAsLocalDateTime () =
54+ runCatching { LocalDateTime .parse(this , datesPattern) }
5255 .getOrDefault(LocalDateTime .of(1 , 1 , 1 , 1 , 1 ))
0 commit comments