You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2026/10/06 18:23:45 UTC

(lucene) branch branch_10x updated: Gjf main 10x backport (#16781)

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_10x by this push:
     new ef740ebd967 Gjf main 10x backport (#16781)
ef740ebd967 is described below

commit ef740ebd967b6d4e5ded658baddf39f4427b05f9
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Tue Oct 6 20:23:40 2026 +0200

    Gjf main 10x backport (#16781)
    
    * Backport of #16713.
    
    * Applied tidy.
---
 .../plugins/spotless/GoogleJavaFormatPlugin.java      |  6 ++++++
 .../plugins/spotless/ParentGoogleJavaFormatTask.java  | 19 +++++++++++++++++--
 gradle/libs.versions.toml                             |  4 ++--
 .../analysis/compound/hyphenation/TernaryTree.java    |  2 --
 .../apache/lucene/analysis/pt/RSLPStemmerBase.java    |  4 ----
 .../lucene/analysis/icu/ICUTransformFilter.java       |  2 --
 .../apache/lucene/benchmark/byTask/package-info.java  |  2 --
 .../org/apache/lucene/index/TieredMergePolicy.java    |  2 ++
 .../java/org/apache/lucene/monitor/package-info.java  |  2 --
 .../flexible/core/nodes/ModifierQueryNode.java        |  2 --
 .../flexible/standard/parser/package-info.java        |  2 --
 .../lucene/queryparser/simple/SimpleQueryParser.java  |  2 --
 12 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/GoogleJavaFormatPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/GoogleJavaFormatPlugin.java
index ae5cefbffe4..aa4c2fef48b 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/GoogleJavaFormatPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/GoogleJavaFormatPlugin.java
@@ -68,10 +68,16 @@ public class GoogleJavaFormatPlugin extends LuceneGradlePlugin {
     tasks.named("check", check -> check.dependsOn(checkTask));
 
     var fileStates = project.getLayout().getBuildDirectory().file("gjf-file-states.json");
+    var formatterVersion =
+        getVersionCatalog(project)
+            .findLibrary("gjf")
+            .orElseThrow()
+            .map(dep -> dep.getModule() + ":" + dep.getVersionConstraint().getRequiredVersion());
     for (var t : List.of(applyTask, checkTask)) {
       t.configure(
           task -> {
             task.getBatchSize().set(batchSizeOption);
+            task.getFormatterVersion().set(formatterVersion);
             task.dependsOn(":" + CheckEnvironmentPlugin.TASK_CHECK_JDK_INTERNALS_EXPOSED_TO_GRADLE);
             task.getFileStateCache().set(fileStates);
           });
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/ParentGoogleJavaFormatTask.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/ParentGoogleJavaFormatTask.java
index 2f52972ed51..c796f1102f3 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/ParentGoogleJavaFormatTask.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/ParentGoogleJavaFormatTask.java
@@ -67,6 +67,13 @@ abstract class ParentGoogleJavaFormatTask extends DefaultTask {
   @PathSensitive(PathSensitivity.RELATIVE)
   public abstract ConfigurableFileCollection getSourceFiles();
 
+  /**
+   * The formatter's coordinates (module and version). Any change invalidates all cached file states
+   * so that every source file is processed again with the new formatter.
+   */
+  @Input
+  public abstract Property<String> getFormatterVersion();
+
   @OutputFile
   public abstract RegularFileProperty getOutputChangeListFile();
 
@@ -143,7 +150,9 @@ abstract class ParentGoogleJavaFormatTask extends DefaultTask {
     if (pathProvider.isPresent()) {
       Files.writeString(
           pathProvider.get().getAsFile().toPath(),
-          JsonOutput.prettyPrint(JsonOutput.toJson(fileStates)));
+          JsonOutput.prettyPrint(
+              JsonOutput.toJson(
+                  Map.of("formatter", getFormatterVersion().get(), "files", fileStates))));
     }
   }
 
@@ -154,7 +163,13 @@ abstract class ParentGoogleJavaFormatTask extends DefaultTask {
       if (Files.exists(path)) {
         try {
           @SuppressWarnings("unchecked")
-          var saved = (Map<String, Map<String, Object>>) new JsonSlurper().parse(path);
+          var root = (Map<String, Object>) new JsonSlurper().parse(path);
+          if (!getFormatterVersion().get().equals(root.get("formatter"))) {
+            // The formatter changed, ignore all stored file states.
+            return checksums;
+          }
+          @SuppressWarnings("unchecked")
+          var saved = (Map<String, Map<String, Object>>) root.get("files");
           var restored =
               saved.entrySet().stream()
                   .collect(
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 09c8d601051..a89130e3e0a 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -17,7 +17,7 @@ errorprone = "2.50.0"
 # markdown documentation generation
 flexmark = "0.64.8"
 # @keep This is GJF version for java source code formatting
-googleJavaFormat = "1.33.0-markdown"
+googleJavaFormat = "1.36.1"
 # gradle build support
 groovy = "6.0.0"
 # test assertions
@@ -76,7 +76,7 @@ flexmark-ext-abbreviation = { module = "com.vladsch.flexmark:flexmark-ext-abbrev
 flexmark-ext-attributes = { module = "com.vladsch.flexmark:flexmark-ext-attributes", version.ref = "flexmark" }
 flexmark-ext-autolink = { module = "com.vladsch.flexmark:flexmark-ext-autolink", version.ref = "flexmark" }
 flexmark-ext-tables = { module = "com.vladsch.flexmark:flexmark-ext-tables", version.ref = "flexmark" }
-gjf = { module = "com.carrotsearch.googlejavaformat:google-java-format", version.ref = "googleJavaFormat" }
+gjf = { module = "com.google.googlejavaformat:google-java-format", version.ref = "googleJavaFormat" }
 groovy = { module = "org.apache.groovy:groovy-all", version.ref = "groovy" }
 hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" }
 icu4j = { module = "com.ibm.icu:icu4j", version.ref = "icu4j" }
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java
index ee75d983a4d..950428b4bce 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java
@@ -22,8 +22,6 @@ import java.util.Deque;
 import java.util.Enumeration;
 
 /**
- *
- *
  * <h2>Ternary Search Tree.</h2>
  *
  * <p>A ternary search tree is a hybrid between a binary tree and a digital search tree (trie). Keys
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/RSLPStemmerBase.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/RSLPStemmerBase.java
index 2a3a468f3b7..e07806b04b8 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/RSLPStemmerBase.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/RSLPStemmerBase.java
@@ -46,9 +46,7 @@ import org.apache.lucene.analysis.CharArraySet;
  * <p>The general rule format is:
  *
  * <blockquote>
- *
  * { "suffix", N, "replacement", { "exception1", "exception2", ...}}
- *
  * </blockquote>
  *
  * where:
@@ -67,9 +65,7 @@ import org.apache.lucene.analysis.CharArraySet;
  * <p>A step is an ordered list of rules, with a structure in this format:
  *
  * <blockquote>
- *
  * { "name", N, B, { "cond1", "cond2", ... } ... rules ... };
- *
  * </blockquote>
  *
  * where:
diff --git a/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUTransformFilter.java b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUTransformFilter.java
index afc54fcb6eb..17d4c484071 100644
--- a/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUTransformFilter.java
+++ b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUTransformFilter.java
@@ -46,9 +46,7 @@ import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
  * <p>Example usage:
  *
  * <blockquote>
- *
  * stream = new ICUTransformFilter(stream, Transliterator.getInstance("Traditional-Simplified"));
- *
  * </blockquote>
  *
  * <br>
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/package-info.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/package-info.java
index 511f161a55e..52141184317 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/package-info.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/package-info.java
@@ -99,13 +99,11 @@
  * DocMaker and implementing QueryMaker.
  *
  * <blockquote>
- *
  * <b>Note:</b> since 2.9, DocMaker is a concrete class which accepts a ContentSource. In most
  * cases, you can use the DocMaker class to create Documents, while providing your own ContentSource
  * implementation. For example, the current Benchmark package includes ContentSource implementations
  * for TREC, Enwiki and Reuters collections, as well as others like LineDocSource which reads a
  * 'line' file produced by WriteLineDocTask.
- *
  * </blockquote>
  *
  * <p>Benchmark .alg file contains the benchmark "algorithm". The syntax is described below. Within
diff --git a/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java b/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java
index 455285482c9..2228f37874c 100644
--- a/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java
+++ b/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java
@@ -294,8 +294,10 @@ public class TieredMergePolicy extends MergePolicy {
 
   private static class SegmentSizeAndDocs {
     private final SegmentCommitInfo segInfo;
+
     /// Size of the segment in bytes, pro-rated by the number of live documents.
     private final long sizeInBytes;
+
     private final int delCount;
     private final int maxDoc;
     private final String name;
diff --git a/lucene/monitor/src/java/org/apache/lucene/monitor/package-info.java b/lucene/monitor/src/java/org/apache/lucene/monitor/package-info.java
index 9ee06fed075..c919d9789e0 100644
--- a/lucene/monitor/src/java/org/apache/lucene/monitor/package-info.java
+++ b/lucene/monitor/src/java/org/apache/lucene/monitor/package-info.java
@@ -16,8 +16,6 @@
  */
 
 /**
- *
- *
  * <h2>Monitoring framework</h2>
  *
  * This package contains classes to allow the monitoring of a stream of documents with a set of
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ModifierQueryNode.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ModifierQueryNode.java
index e367b70e8c9..53877080c22 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ModifierQueryNode.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/ModifierQueryNode.java
@@ -28,11 +28,9 @@ import org.apache.lucene.queryparser.flexible.messages.MessageImpl;
  * string. For example "+t1 -t2 t3" will have a tree of:
  *
  * <blockquote>
- *
  * &lt;BooleanQueryNode&gt; &lt;ModifierQueryNode modifier="MOD_REQ"&gt; &lt;t1/&gt;
  * &lt;/ModifierQueryNode&gt; &lt;ModifierQueryNode modifier="MOD_NOT"&gt; &lt;t2/&gt;
  * &lt;/ModifierQueryNode&gt; &lt;t3/&gt; &lt;/BooleanQueryNode&gt;
- *
  * </blockquote>
  */
 public class ModifierQueryNode extends QueryNodeImpl {
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/package-info.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/package-info.java
index dba0de2e406..fcbe8cb47ea 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/package-info.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/package-info.java
@@ -16,8 +16,6 @@
  */
 
 /**
- *
- *
  * <h2>Lucene Query Parser</h2>
  *
  * <p>The package org.apache.lucene.queryparser.flexible.standard.parser contains the query parser.
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/simple/SimpleQueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/simple/SimpleQueryParser.java
index e16b2ede269..171d832d5aa 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/simple/SimpleQueryParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/simple/SimpleQueryParser.java
@@ -65,9 +65,7 @@ import org.apache.lucene.util.automaton.LevenshteinAutomata;
  * will evaluate {@code token1 OR token2} first, then {@code AND} with {@code token3}:
  *
  * <blockquote>
- *
  * token1 | token2 + token3
- *
  * </blockquote>
  *
  * <b>Escaping</b>