littlerobots / version-catalog-update-plugin

Gradle plugin for updating a project version catalog
Apache License 2.0
565 stars 23 forks source link

build.gradle.kts: Unexpected tokens #151

Closed milahu closed 1 month ago

milahu commented 1 month ago

the readme says

In your `build.gradle[.kts]`: ``` plugins { id "com.github.ben-manes.versions" version "0.41.0" id "nl.littlerobots.version-catalog-update" version "" } ```

but this does not work with build.gradle.kts

i tried to add version-catalog-update-plugin to gradle2nix/build.gradle.kts

--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,6 +1,8 @@
 plugins {
     base
     alias(libs.plugins.kotlin.serialization) apply false
+    id "com.github.ben-manes.versions" version "0.41.0"
+    id "nl.littlerobots.version-catalog-update" version "<latest version>"
 }

 group = "org.nixos.gradle2nix"

but then gradlew versionCatalogUpdate fails with

  Line 4:     id "com.github.ben-manes.versions" version "0.41.0"
                 ^ Unexpected tokens (use ';' to separate expressions on the same line)
``` $ ./gradlew versionCatalogUpdate Calculating task graph as no cached configuration is available for tasks: versionCatalogUpdate > Task :buildSrc:checkKotlinGradlePluginConfigurationErrors > Task :buildSrc:generateExternalPluginSpecBuilders UP-TO-DATE > Task :buildSrc:extractPrecompiledScriptPluginPlugins UP-TO-DATE > Task :buildSrc:compilePluginsBlocks UP-TO-DATE > Task :buildSrc:generatePrecompiledScriptPluginAccessors UP-TO-DATE > Task :buildSrc:generateScriptPluginAdapters UP-TO-DATE > Task :buildSrc:compileKotlin UP-TO-DATE > Task :buildSrc:compileJava NO-SOURCE > Task :buildSrc:compileGroovy NO-SOURCE > Task :buildSrc:pluginDescriptors UP-TO-DATE > Task :buildSrc:processResources UP-TO-DATE > Task :buildSrc:classes UP-TO-DATE > Task :buildSrc:jar UP-TO-DATE > Configure project : e: file:///tmp/gradle2nix/build.gradle.kts:4:8: Unexpected tokens (use ';' to separate expressions on the same line) e: file:///tmp/gradle2nix/build.gradle.kts:5:8: Unexpected tokens (use ';' to separate expressions on the same line) e: file:///tmp/gradle2nix/build.gradle.kts:4:5: Function invocation 'id(...)' expected e: file:///tmp/gradle2nix/build.gradle.kts:4:5: No value passed for parameter 'id' e: file:///tmp/gradle2nix/build.gradle.kts:5:5: Function invocation 'id(...)' expected e: file:///tmp/gradle2nix/build.gradle.kts:5:5: No value passed for parameter 'id' FAILURE: Build failed with an exception. * Where: Build file '/tmp/gradle2nix/build.gradle.kts' line: 4 * What went wrong: Script compilation errors: Line 4: id "com.github.ben-manes.versions" version "0.41.0" ^ Unexpected tokens (use ';' to separate expressions on the same line) Line 4: id "com.github.ben-manes.versions" version "0.41.0" ^ Function invocation 'id(...)' expected Line 4: id "com.github.ben-manes.versions" version "0.41.0" ^ No value passed for parameter 'id' Line 5: id "nl.littlerobots.version-catalog-update" version "" ^ Unexpected tokens (use ';' to separate expressions on the same line) Line 5: id "nl.littlerobots.version-catalog-update" version "" ^ Function invocation 'id(...)' expected Line 5: id "nl.littlerobots.version-catalog-update" version "" ^ No value passed for parameter 'id' 6 errors * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 3s 10 actionable tasks: 1 executed, 9 up-to-date Configuration cache entry stored. ```

from the gradle docs i learned that the plugins block in build.gradle.kts should look like

plugins {
  id("com.github.ben-manes.versions") version "0.41.0"
  id("nl.littlerobots.version-catalog-update") version "<latest version>"
}

now gradlew versionCatalogUpdate fails with

could not resolve plugin artifact 'nl.littlerobots.version-catalog-update:nl.littlerobots.version-catalog-update.gradle.plugin:<latest version>'

ok, let me set an actual version in build.gradle.kts

plugins {
  id("com.github.ben-manes.versions") version "0.41.0"
  id("nl.littlerobots.version-catalog-update") version "0.8.4"
}

ok, this build.gradle.kts seems to work