gradle-dependencies-sorter icon indicating copy to clipboard operation
gradle-dependencies-sorter copied to clipboard

Feature request: silently-no-op on build files with no dependencies blocks

Open ZacSweers opened this issue 2 years ago • 2 comments
trafficstars

The following build file results in a parse error

import slack.gradle.Platforms

plugins {
  alias(libs.plugins.slack.base)
  `java-platform`
}

val catalogExtension =
  extensions.findByType<VersionCatalogsExtension>() ?: error("Could not find any version catalogs!")

for (name in catalogExtension.catalogNames) {
  val catalog = catalogExtension.named(name)
  Platforms.applyFromCatalog(project, catalog)
}

This is the log file

INFO: Sorting build.gradle(.kts) scripts in the following paths: /Users/zacsweers/dev/slack/slack-android-ng/tooling/slack-platform/build.gradle.kts
INFO: It took 31 ms to find 1 build scripts.
WARN: Parsing error: /Users/zacsweers/dev/slack/slack-android-ng/tooling/slack-platform/build.gradle.kts 
1: extraneous input 'project' expecting {<EOF>, DEPENDENCIES, 'file(', 'files(', 'buildscript', '{', '}', '(', ')', ''', '"', '=', ';', '\', UNICODE_LATIN, ID, DIGIT, WS}
INFO: Metrics:
  Successful sorts: 0
  Already sorted:   0
  Parse errors:     1

Sort duration: 45 ms.

ZacSweers avatar Feb 07 '23 18:02 ZacSweers

Thanks for the issue. Seems valid! PRs welcome.

autonomousapps avatar Jul 17 '23 04:07 autonomousapps

I think this might already work? I have a test for empty build files.

autonomousapps avatar Dec 01 '23 20:12 autonomousapps