Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -756,13 +756,17 @@ tasks.register("tags", Exec) {
description = "Create Emacs TAGS table"
group = "Emacs"
// running this task will also run the tags task in the subprojects, which is defined later in this file.
commandLine("etags", "-i", "annotation-file-utilities/TAGS", "-i", "buildSrc/TAGS", "-i", "checker/TAGS", "-i", "checker-qual/TAGS", "-i", "checker-util/TAGS", "-i", "dataflow/TAGS", "-i", "framework/TAGS", "-i", "framework-test/TAGS", "-i", "javacutil/TAGS", "-i", "docs/manual/TAGS")
commandLine("etags", "-i", "annotation-file-utilities/TAGS", "-i", "buildSrc/TAGS", "-i", "checker/TAGS", "-i", "checker-qual/TAGS", "-i", "checker-util/TAGS", "-i", "dataflow/TAGS", "-i", "framework/TAGS", "-i", "framework-test/TAGS", "-i", "javacutil/TAGS", "-i", "docs/manual/TAGS", "-i", "buildSrc/TAGS")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}

subprojects {
// This is a locally built "plugin" that contains the spotless configuration. It is in
// buildSrc/src/main/groovy/cf-spotless.gradle.
apply plugin: "cf-spotless"

if (!project.name.startsWith("checker-qual-android")) {
apply plugin: "tags"
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
configurations {
annotatedGuava
}
Expand All @@ -776,14 +780,6 @@ subprojects {
}
}

if (!project.name.startsWith("checker-qual-android")) {
tasks.register("tags", Exec) {
description = "Create Emacs TAGS table"
// `ctags -e -f TAGS` used to work in place of `etags`, but apparently no longer.
commandLine("bash", "-c", "find . \\( -name build -o -name jtreg -o -name tests \\) -prune -o -name '*.java' -print | sort-directory-order | xargs etags")
}
}

java {
withJavadocJar()
withSourcesJar()
Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("groovy-gradle-plugin")
id("java")
}
apply from: file("src/main/groovy/tags.gradle")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

repositories {
gradlePluginPortal()
Expand Down
5 changes: 5 additions & 0 deletions buildSrc/src/main/groovy/tags.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tasks.register("tags", Exec) {
description = "Create Emacs TAGS table"
// `ctags -e -f TAGS` used to work in place of `etags`, but apparently no longer.
commandLine("bash", "-c", "find . \\( -name build -o -name jtreg -o -name tests \\) -prune -o -name '*.java' -print | sort-directory-order | xargs etags")
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Does GNU etags overwrite the TAGS file on each invocation by default, and does the -a/--append flag cause it to append instead?

💡 Result:

Yes, GNU etags overwrites the TAGS file on each invocation by default. Without the -a/--append flag, it creates a new TAGS file (default name) containing tags only from the specified input files. The -a/--append flag causes it to append new tags to an existing TAGS file instead of overwriting it.

Citations:


🏁 Script executed:

# Verify the actual file exists and check its content
find . -path "*/buildSrc/src/main/groovy/tags.gradle" -type f

Repository: typetools/checker-framework

Length of output: 109


🏁 Script executed:

# Search for the root build.gradle and look for tags/docTags task definitions
find . -maxdepth 2 -name "build.gradle" -type f | head -20

Repository: typetools/checker-framework

Length of output: 369


🏁 Script executed:

# Search for references to "group = " in build.gradle files to confirm Emacs group
rg "group\s*=\s*[\"']Emacs[\"']" --type groovy -B 2 -A 2

Repository: typetools/checker-framework

Length of output: 842


🏁 Script executed:

# Check if sort-directory-order is defined in the repository
rg "sort-directory-order" --type groovy --type sh --type bash

Repository: typetools/checker-framework

Length of output: 99


🏁 Script executed:

# Read the actual tags.gradle file to confirm the code snippet
cat -n ./buildSrc/src/main/groovy/tags.gradle

Repository: typetools/checker-framework

Length of output: 421


🏁 Script executed:

# Search for sort-directory-order without type specification
rg "sort-directory-order" -A 3 -B 3

Repository: typetools/checker-framework

Length of output: 571


🏁 Script executed:

# Check if there's a sort-directory-order script/executable in the repo
fd "sort-directory-order" -type f

Repository: typetools/checker-framework

Length of output: 241


🏁 Script executed:

# Search for sort-directory-order anywhere in the repo
rg "sort-directory-order"

Repository: typetools/checker-framework

Length of output: 264


🏁 Script executed:

# Check if it's defined in plume-scripts or is an external utility
rg "def sort-directory-order" -A 5

Repository: typetools/checker-framework

Length of output: 53


🏁 Script executed:

# Look for where plume-scripts or similar utilities are sourced
rg "plume" --max-count 10

Repository: typetools/checker-framework

Length of output: 50383


🏁 Script executed:

# Check the root build.gradle for how the tags task incorporates subproject tags
cat -n ./build.gradle | grep -A 20 "tasks.register.*tags"

Repository: typetools/checker-framework

Length of output: 1059


🏁 Script executed:

# Check if there's documentation or implementation of sort-directory-order in plume-scripts
rg "sort-directory-order" -A 10 -B 2 | head -50

Repository: typetools/checker-framework

Length of output: 503


🏁 Script executed:

# Look for any test or usage examples of sort-directory-order with -z flag
rg "\-print0\|\-0\|\s-z\s" --max-count 20

Repository: typetools/checker-framework

Length of output: 53


🏁 Script executed:

# Check if the plume-scripts repo or reference is present
ls -la checker/bin-devel/.plume-scripts 2>/dev/null || echo "plume-scripts not checked out"

Repository: typetools/checker-framework

Length of output: 100


🏁 Script executed:

# Verify the actual impact by checking the sizes of source trees in affected subprojects
find checker/src -name "*.java" | wc -l
find framework/src -name "*.java" | wc -l
find dataflow/src -name "*.java" | wc -l

Repository: typetools/checker-framework

Length of output: 82


Add group = "Emacs" and fix xargs truncation hazard in the tags task.

Two issues:

  1. xargs can truncate TAGS on large subprojects. When the Java file list exceeds ARG_MAX, xargs invokes etags multiple times; since etags overwrites the TAGS file by default, only the last batch's entries survive. This plugin is now applied to all non-checker-qual-android subprojects (checker, framework, dataflow, etc.), some of which may plausibly exceed the limit when combined. Use rm -f TAGS; find … | xargs etags -a to start fresh and append instead.

  2. Missing group declaration. The root build.gradle assigns group = "Emacs" to both the tags and docTags tasks. Add it here for consistency.

Proposed fix
 tasks.register("tags", Exec) {
   description = "Create Emacs TAGS table"
+  group = "Emacs"
   // `ctags -e -f TAGS` used to work in place of `etags`, but apparently no longer.
-  commandLine("bash", "-c", "find . \\( -name build -o -name jtreg -o -name tests \\) -prune -o -name '*.java' -print | sort-directory-order | xargs etags")
+  commandLine("bash", "-c", "rm -f TAGS && find . \\( -name build -o -name jtreg -o -name tests \\) -prune -o -type f -name '*.java' -print0 | sort-directory-order -z | xargs -0 etags -a")
 }

Note: Verify that your sort-directory-order supports the -z flag for NUL-delimited input. If not, omit -print0, -0, and -z, but keep the rm -f TAGS + etags -a pair, which is the critical fix.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@buildSrc/src/main/groovy/tags.gradle` around lines 1 - 5, Update the "tags"
task to set group = "Emacs" and make the etags invocation safe against ARG_MAX
truncation: before running etags remove any existing TAGS (rm -f TAGS) and
invoke etags in append mode (-a) so multiple xargs batches accumulate instead of
overwriting; use NUL-delimited find/xargs (find -print0 | sort-directory-order
-z | xargs -0 etags -a) if your sort-directory-order supports -z, otherwise keep
the rm -f TAGS + etags -a pattern with the existing whitespace-delimited
pipeline to ensure all batches are appended.