Repository navigation
Wire central catalog refresh - #1
riccardobl wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new refreshCatalog Gradle task to download and update the central NostrGameEngine version catalog, and adds the initial gradle/libs.versions.toml file. Feedback on the new task suggests ensuring it always runs when explicitly executed by disabling up-to-date checks, and improving network resilience and encoding consistency by adding connection/read timeouts and explicitly writing the output file in UTF-8.
| .orElse('https://raw.githubusercontent.com/NostrGameEngine/libs.catalog/main/libs.versions.toml') | ||
| def outputFile = layout.projectDirectory.file('gradle/libs.versions.toml') | ||
|
|
||
| outputs.file(outputFile) |
There was a problem hiding this comment.
Because gradle/libs.versions.toml is committed to the repository, it will always exist. Since this task defines an output file but no inputs, Gradle's up-to-date check will consider the task UP-TO-DATE and skip execution on subsequent runs, preventing the catalog from actually being refreshed.
To ensure the catalog is always refreshed when this task is explicitly executed, configure the task to never be considered up-to-date by adding outputs.upToDateWhen { false }.
outputs.file(outputFile)
outputs.upToDateWhen { false }
| doLast { | ||
| def target = outputFile.asFile | ||
| target.parentFile.mkdirs() | ||
| target.text = new URI(catalogUrl.get()).toURL().getText('UTF-8') |
There was a problem hiding this comment.
There are two potential issues with the current file download and write implementation:
- Missing Timeouts:
URL.getText(String)does not have a default timeout, which can cause the Gradle build to hang indefinitely if the network connection is flaky or the remote server is unresponsive. - Platform-Default Encoding: Assigning a string directly to
target.textuses the platform's default encoding to write the file. This can lead to encoding discrepancies or corruption of non-ASCII characters when run on different operating systems (e.g., Windows vs. Linux).
Using URL.getText(Map, String) with explicit connectTimeout and readTimeout parameters, and writing the file using target.setText(text, charset) ensures both network resilience and platform-independent UTF-8 encoding.
target.setText(new URI(catalogUrl.get()).toURL().getText(connectTimeout: 10000, readTimeout: 10000, 'UTF-8'), 'UTF-8')
Summary
refreshCatalogGradle task that downloadsNostrGameEngine/libs.catalog.refresh-catalog.ymlworkflow that opens a PR only when the refreshed catalog changes.Verification
tomllib.YAML.load_file../gradlew --no-daemon -q refreshCatalogsuccessfully inbech32as the representative Groovy Gradle task.Note: local Kotlin-task execution in
cap-cache-generatorwas blocked before task execution because the machine ran out of disk space while the Gradle wrapper tried to install Gradle 8.4.