Apache Lucene open-source search software
Convert help files to markdown (#16584)
Dawid Weiss818a1a4a3340
diff --git a/.typos.toml b/.typos.tomlindex bef5816adb2..4d14b2b646c 100644--- a/.typos.toml+++ b/.typos.toml@@ -56,7 +56,7 @@ check-file = true[type.help]check-file = true-extend-glob = [ "help/*.txt"]+extend-glob = [ "help/*.md"][type.html]check-file = truediff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex cf0c952d3a1..80a1b9cf434 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -37,33 +37,33 @@ Some build tasks (in particular `./gradlew check`) require Perl and Python 3.### Building with Gradle-Lucene uses [Gradle](https://gradle.org/) for build control. Gradle is itself Java-based and may be incompatible with newer Java versions; you can still build and test Lucene with these Java releases, see [jvms.txt](./help/jvms.txt) for more information.+Lucene uses [Gradle](https://gradle.org/) for build control. Gradle is itself Java-based and may be incompatible with newer Java versions; you can still build and test Lucene with these Java releases, see [help/jvms.md](./help/jvms.md) for more information.NOTE: DO NOT use the `gradle` command that is perhaps installed on your machine. This may result in using a different gradle version than the project requires and this is known to lead to very cryptic errors. The "gradle wrapper" (`gradlew` script) does everything required to build the project from scratch: it downloads the correct version of gradle, sets up sane local configurations and is tested on multiple environments.The first time you run gradlew, it will create a file "gradle.properties" that contains machine-specific settings. Normally you can use this file as-is, but it can be modified if necessary.-Type `./gradlew helpWorkflow` to show typical workflow tasks ([help/workflow.txt](./help/workflow.txt)).+Type `./gradlew helpWorkflow` to show typical workflow tasks ([help/workflow.md](./help/workflow.md)).Also run `./gradlew help`, this will print a list of help guides that introduce and explainvarious parts of the build system, including typical workflow tasks.### Code formatting and checks-Lucene uses [prek](https://github.com/j178/prek) for fast pre-commit validation. Validate your staged changes with `uvx prek`, Type `./gradlew helpPrecommit` for more information: [help/precommit.txt](help/precommit.txt).+Lucene uses [prek](https://github.com/j178/prek) for fast pre-commit validation. Validate your staged changes with `uvx prek`, Type `./gradlew helpPrecommit` for more information: [help/precommit.md](./help/precommit.md).-If you've modified any sources, run `./gradlew tidy` to apply code formatting conventions automatically (see [help/formatting.txt](https://github.com/apache/lucene/blob/main/help/formatting.txt)).+If you've modified any sources, run `./gradlew tidy` to apply code formatting conventions automatically (see [help/formatting.md](./help/formatting.md)).-Please make sure that all unit tests and validations succeed before constructing your patch: `./gradlew check`. This will assemble Lucene and run all validation tasks (including tests). There are various commands to check the code; type `./gradlew helpTest` for more information ([help/tests.txt](./help/tests.txt)).+Please make sure that all unit tests and validations succeed before constructing your patch: `./gradlew check`. This will assemble Lucene and run all validation tasks (including tests). There are various commands to check the code; type `./gradlew helpTest` for more information ([help/tests.md](./help/tests.md)).In case your contribution fixes a bug, please create a new test case that fails before your fix, to show the presence of the bug and ensure it never re-occurs. A test case showing the presence of a bug is also a good contribution by itself.### IDE support- *IntelliJ* - IntelliJ idea can import and build gradle-based projects out of the box. It will default to running tests by calling the gradle wrapper, and while this works, it is can be a bit slow. If instead you configure IntelliJ to use its own built-in test runner by (in 2024 version) navigating to settings for Build Execution & Deployment/Build Tools/Gradle (under File/Settings menu on some platforms) and selecting "Build and Run using: IntelliJ IDEA" and "Run Tests using: IntelliJ IDEA", then some tests will run faster. However some other tests will not run using this configuration.-- *Eclipse* - Basic support ([help/IDEs.txt](https://github.com/apache/lucene/blob/main/help/IDEs.txt#L7)).-- *VSCode* - Basic support ([help/IDEs.txt](https://github.com/apache/lucene/blob/main/help/IDEs.txt#L23)).-- *Neovim* - Basic support ([help/IDEs.txt](https://github.com/apache/lucene/blob/main/help/IDEs.txt#L32)).+- *Eclipse* - Basic support ([help/IDEs.md](./help/IDEs.md#eclipse)).+- *VSCode* - Basic support ([help/IDEs.md](./help/IDEs.md#vscode)).+- *Neovim* - Basic support ([help/IDEs.md](./help/IDEs.md#neovim)).- *Netbeans* - Not tested.## Benchmarkingdiff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/licenses/CheckLicensesPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/licenses/CheckLicensesPlugin.javaindex 7afa196004f..bebe2d6948a 100644--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/licenses/CheckLicensesPlugin.java+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/licenses/CheckLicensesPlugin.java@@ -105,7 +105,7 @@ public class CheckLicensesPlugin extends LuceneGradlePlugin {"build-options.properties","dev-tools/**","gradle/**",- "help/*.txt",+ "help/*.md","lucene/licenses/*","versions.lock",diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/ConfigureLockFilePlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/ConfigureLockFilePlugin.javaindex ee4a8276995..3ec56b5e8d9 100644--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/ConfigureLockFilePlugin.java+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/ConfigureLockFilePlugin.java@@ -26,7 +26,7 @@ import org.gradle.api.Project;* Configure dependency checks plugin which validates and updates the top-level {@code* versions.lock}, taking care of cross-configuration consistency of transitive dependencies.*- * @see "https://github.com/apache/lucene/blob/main/help/dependencies.txt"+ * @see "https://github.com/apache/lucene/blob/main/help/dependencies.md"* @see* "https://github.com/carrotsearch/gradle-build-infra#plugin-comcarrotsearchgradlebuildinfradependencychecksdependencychecksplugin"*/diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.javaindex f33986fdd99..49cb524831d 100644--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.java+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.java@@ -28,37 +28,37 @@ import org.gradle.api.GradleException;import org.gradle.api.Project;import org.gradle.api.tasks.StopExecutionException;-/** Configures "helpXyz" tasks which display plain text files under 'help' folder. */+/** Configures "helpXyz" tasks which display markdown files under 'help' folder as plain text. */public class HelpPlugin extends LuceneGradlePlugin {record HelpFile(String name, String path, String description) {}private static final List<HelpFile> helpFiles =List.of(- new HelpFile("Workflow", "help/workflow.txt", "Typical workflow commands."),- new HelpFile("Tests", "help/tests.txt", "Tests, filtering, beasting, etc."),- new HelpFile("Precommit", "help/precommit.txt", "Precommit checks."),- new HelpFile("Formatting", "help/formatting.txt", "Code formatting conventions."),- new HelpFile("Jvms", "help/jvms.txt", "Using alternative or EA JVM toolchains."),+ new HelpFile("Workflow", "help/workflow.md", "Typical workflow commands."),+ new HelpFile("Tests", "help/tests.md", "Tests, filtering, beasting, etc."),+ new HelpFile("Precommit", "help/precommit.md", "Precommit checks."),+ new HelpFile("Formatting", "help/formatting.md", "Code formatting conventions."),+ new HelpFile("Jvms", "help/jvms.md", "Using alternative or EA JVM toolchains."),new HelpFile(- "Deps", "help/dependencies.txt", "Declaring, inspecting and excluding dependencies."),+ "Deps", "help/dependencies.md", "Declaring, inspecting and excluding dependencies."),new HelpFile("ForbiddenApis",- "help/forbiddenApis.txt",+ "help/forbiddenApis.md","How to add/apply rules for forbidden APIs."),new HelpFile("LocalSettings",- "help/localSettings.txt",+ "help/localSettings.md","Local settings, overrides and build performance tweaks."),new HelpFile("Regeneration",- "help/regeneration.txt",+ "help/regeneration.md","How to refresh generated and derived resources."),- new HelpFile("Jmh", "help/jmh.txt", "JMH micro-benchmarks."),- new HelpFile("Git", "help/git.txt", "Git assistance and guides."),- new HelpFile("IDEs", "help/IDEs.txt", "IDE support."),+ new HelpFile("Jmh", "help/jmh.md", "JMH micro-benchmarks."),+ new HelpFile("Git", "help/git.md", "Git assistance and guides."),+ new HelpFile("IDEs", "help/IDEs.md", "IDE support."),new HelpFile("Publishing",- "help/publishing.txt",+ "help/publishing.md","Maven and other artifact publishing, signing, etc."));@Override@@ -77,7 +77,7 @@ public class HelpPlugin extends LuceneGradlePlugin {task.doFirst(_ -> {try {- println("\n" + Files.readString(helpFilePath));+ println("\n" + MarkdownToText.render(Files.readString(helpFilePath)));} catch (IOException e) {throw new UncheckedIOException(e);}@@ -115,7 +115,6 @@ public class HelpPlugin extends LuceneGradlePlugin {});});- // ensure all help files exist.// Make sure all help files exist.var helpDir = getProjectRootPath(rootProject).resolve("help");var allHelpFilesExist =@@ -140,8 +139,8 @@ public class HelpPlugin extends LuceneGradlePlugin {helpFiles.stream().map(v -> v.path).collect(Collectors.toSet());if (!existing.equals(expected)) {throw new GradleException(- "help/*.txt help files are not consistent with the descriptions"- + "in the "+ "help/*.md help files are not consistent with the descriptions"+ + " in the "+ getClass().getName());}} catch (IOException e) {diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/MarkdownToText.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/MarkdownToText.javanew file mode 100644index 00000000000..d6b00ef7d06--- /dev/null+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/MarkdownToText.java@@ -0,0 +1,118 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.lucene.gradle.plugins.misc;++import com.vladsch.flexmark.ast.BlockQuote;+import com.vladsch.flexmark.ast.FencedCodeBlock;+import com.vladsch.flexmark.ast.HardLineBreak;+import com.vladsch.flexmark.ast.Heading;+import com.vladsch.flexmark.ast.IndentedCodeBlock;+import com.vladsch.flexmark.ast.Link;+import com.vladsch.flexmark.ast.LinkNodeBase;+import com.vladsch.flexmark.ast.ListBlock;+import com.vladsch.flexmark.ast.OrderedList;+import com.vladsch.flexmark.ast.Paragraph;+import com.vladsch.flexmark.ast.SoftLineBreak;+import com.vladsch.flexmark.ast.Text;+import com.vladsch.flexmark.ast.ThematicBreak;+import com.vladsch.flexmark.parser.Parser;+import com.vladsch.flexmark.util.ast.Node;+import com.vladsch.flexmark.util.sequence.Escaping;++/** Renders markdown as plain text for console output (flexmark AST walk, paragraphs wrapped). */+final class MarkdownToText {+ private static final int WIDTH = 100;+ private final StringBuilder out = new StringBuilder();++ static String render(String markdown) {+ var r = new MarkdownToText();+ r.blocks(Parser.builder().build().parse(markdown), "", true);+ return r.out.toString().stripTrailing() + "\n";+ }++ private void blocks(Node parent, String indent, boolean loose) {+ for (Node n = parent.getFirstChild(); n != null; n = n.getNext()) {+ if (loose && n != parent.getFirstChild()) out.append('\n');+ block(n, indent);+ }+ }++ private void block(Node n, String indent) {+ switch (n) {+ case Heading h -> {+ String text = inlines(h);+ line(indent, text);+ if (h.getLevel() <= 2) line(indent, (h.getLevel() == 1 ? "=" : "-").repeat(text.length()));+ }+ case Paragraph p -> wrap(indent, inlines(p));+ case FencedCodeBlock c ->+ c.getContentChars().toString().lines().forEach(l -> line(indent + " ", l));+ case IndentedCodeBlock c ->+ c.getContentChars().toString().lines().forEach(l -> line(indent + " ", l));+ case BlockQuote q -> blocks(q, indent + " ", true);+ case ThematicBreak _ -> line(indent, "-".repeat(WIDTH - indent.length()));+ case ListBlock l -> {+ int num = l instanceof OrderedList ol ? ol.getStartNumber() : 0;+ for (Node item = l.getFirstChild(); item != null; item = item.getNext(), num++) {+ if (l.isLoose() && item != l.getFirstChild()) out.append('\n');+ String marker = l instanceof OrderedList ? num + ". " : "- ";+ int start = out.length() + indent.length();+ blocks(item, indent + " ".repeat(marker.length()), l.isLoose());+ if (out.length() > start) out.replace(start, start + marker.length(), marker);+ else line(indent, marker.stripTrailing());+ }+ }+ default -> n.getChars().toString().lines().forEach(l -> line(indent, l));+ }+ }++ private String inlines(Node parent) {+ var sb = new StringBuilder();+ for (Node n = parent.getFirstChild(); n != null; n = n.getNext()) {+ switch (n) {+ case Link l -> {+ String text = inlines(l), url = l.getUrl().toString();+ sb.append(text.equals(url) ? url : text + " (" + url + ")");+ }+ case LinkNodeBase l -> sb.append(l.getUrl());+ case SoftLineBreak _ -> sb.append(' ');+ case HardLineBreak _ -> sb.append('\n');+ case Text t -> sb.append(Escaping.unescapeString(t.getChars().toString()));+ default -> sb.append(n.getChars());+ }+ }+ return sb.toString();+ }++ private void wrap(String indent, String text) {+ for (String para : text.split("\n")) {+ var sb = new StringBuilder();+ for (String word : para.split("\\s+")) {+ if (!sb.isEmpty() && indent.length() + sb.length() + 1 + word.length() > WIDTH) {+ line(indent, sb.toString());+ sb.setLength(0);+ }+ sb.append(sb.isEmpty() ? "" : " ").append(word);+ }+ line(indent, sb.toString());+ }+ }++ private void line(String indent, String s) {+ out.append(s.isEmpty() ? "" : indent).append(s).append('\n');+ }+}diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/publishing/ConfigureMavenPublishingPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/publishing/ConfigureMavenPublishingPlugin.javaindex af02abd041f..a50b5a80542 100644--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/publishing/ConfigureMavenPublishingPlugin.java+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/publishing/ConfigureMavenPublishingPlugin.java@@ -275,7 +275,7 @@ public class ConfigureMavenPublishingPlugin extends LuceneGradlePlugin {throw new GradleException("'"+ propName- + "' project property must be set when using external GPG via 'useGpg', please see help/publishing.txt");+ + "' project property must be set when using external GPG via 'useGpg', please see help/publishing.md");}for (var p : project.getAllprojects()) {diff --git a/dev-tools/scripts/releaseWizard.yaml b/dev-tools/scripts/releaseWizard.yamlindex 5b2ac6afa0c..230fd6dddec 100644--- a/dev-tools/scripts/releaseWizard.yaml+++ b/dev-tools/scripts/releaseWizard.yaml@@ -253,7 +253,7 @@ groups:fingerprint for the key.You can choose between signing the release with the gpg program or with the- gradle signing plugin. Read about the difference in https://github.com/apache/lucene/blob/main/help/publishing.txt+ gradle signing plugin. Read about the difference in https://github.com/apache/lucene/blob/main/help/publishing.mdThis wizard can prompt you securely for your passphrase (will not be stored) and pass it on tobuildAndPushRelease in a secure way. However, you can also configure your passphrase in advance@@ -265,7 +265,7 @@ groups:- https://infra.apache.org/openpgp.html#apache-wot- https://id.apache.org- https://dist.apache.org/repos/dist/release/lucene/KEYS- - https://github.com/apache/lucene/blob/main/help/publishing.txt+ - https://github.com/apache/lucene/blob/main/help/publishing.md- !TodoGroupid: preparationtitle: Prepare for the releasediff --git a/gradle/template.gradle.properties b/gradle/template.gradle.propertiesindex 1e808746e1b..3105b868702 100644--- a/gradle/template.gradle.properties+++ b/gradle/template.gradle.properties@@ -49,7 +49,7 @@# tests.minheapsize=512m# tests.jvmargs=-XX:+UseParallelGC -XX:TieredStopAtLevel=1#-# See help/localSettings.txt for ways to discover which build options are available and+# See help/localSettings.md for ways to discover which build options are available and# how you can tweak them.##################diff --git a/help/IDEs.md b/help/IDEs.mdnew file mode 100644index 00000000000..e24e6b54ce2--- /dev/null+++ b/help/IDEs.md@@ -0,0 +1,71 @@+# IDE support++## IntelliJ IDEA++Importing the project as a gradle project should just run out of the box.++## Eclipse++Run the following to set up Eclipse project files:++```bash+./gradlew eclipse+```++then import the project into Eclipse with:++```text+File -> Import... -> Existing Project into Workspace+```++Please note that Eclipse does not distinguish between sub-projects and package sets (main/ test) so pretty much all+the sources and dependencies are available in one large bin.++## VSCode++Run the following to set up Eclipse project files:++```bash+./gradlew eclipse+```++Open the lucene checkout in VSCode.++## GitHub Codespaces++- Fork the apache/lucene repository+- Browse to <https://github.com/codespaces/new>+- Repository: yourfork/lucene+- Click "Create codespace"++## Neovim++Run the following to set up Eclipse project files:++```bash+./gradlew eclipse+```++Install jdtls: <https://projects.eclipse.org/projects/eclipse.jdt.ls>++Create `lsp/jdtls.lua`, see <https://github.com/neovim/nvim-lspconfig> for example. Modify `lsp/jdtls.lua` to disable+gradle/maven integration:++```lua+init_options = {+ settings = {+ java = {+ import = {+ gradle = {+ enabled = false,+ },+ maven = {+ enabled = false,+ },+ },+ },+ },+},+```++Enable `jdtls` language server with `vim.lsp.enable()`diff --git a/help/IDEs.txt b/help/IDEs.txtdeleted file mode 100644index 86667bad621..00000000000--- a/help/IDEs.txt+++ /dev/null@@ -1,68 +0,0 @@-IntelliJ IDEA-=============--Importing the project as a gradle project should just run out of the box.---Eclipse-=======--Run the following to set up Eclipse project files:--./gradlew eclipse--then import the project into Eclipse with:--File -> Import... -> Existing Project into Workspace--Please note that Eclipse does not distinguish between sub-projects-and package sets (main/ test) so pretty much all the sources and dependencies-are available in one large bin.---VSCode-======--Run the following to set up Eclipse project files:--./gradlew eclipse--Open the lucene checkout in VSCode.--GitHub Codespaces-=====--Fork the apache/lucene repository--Browse to https://github.com/codespaces/new--Repository: yourfork/lucene-Click "Create codespace"--Neovim-======--Run the following to set up Eclipse project files:--./gradlew eclipse--Install jdtls: https://projects.eclipse.org/projects/eclipse.jdt.ls-Create lsp/jdtls.lua, see https://github.com/neovim/nvim-lspconfig for example.-Modify lsp/jdtls.lua to disable gradle/maven integration:-- init_options = {- settings = {- java = {- import = {- gradle = {- enabled = false,- },- maven = {- enabled = false,- },- },- },- },- },--Enable 'jdtls' language server with vim.lsp.enable()diff --git a/help/dependencies.md b/help/dependencies.mdnew file mode 100644index 00000000000..a02d12412dc--- /dev/null+++ b/help/dependencies.md@@ -0,0 +1,128 @@+# Dependencies++Each gradle project can have multiple (named) "configurations" and each configuration can have dependencies attached+to it.++There are some standard conventions so, for example, the Java plugin adds standard configurations such as `api`,+`implementation`, `testImplementation` and others. These configurations can also inherit from each other; more about+this topic can be found here:++- <https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html#dependency_management_for_java_projects>+- <https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation>+- <https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_plugin_and_dependency_management>++Lucene uses the following configurations and attach project dependencies to them:++- `moduleApi` - makes the dependency available to main classes, tests and any other modules importing the project (exportable dependency),+- `moduleImplementation` - makes the dependency available to main classes, tests but will *not* export the dependency to other modules (so their compilation classpath won't contain it).+- `moduleTestImplementation` - makes the dependency available for test classes only.++The `module` prefix is used to distinguish configurations which apply to modular builds, compared to the regular+classpath-configurations defined by gradle's java module. Some Lucene modules may define regular classpath entries to+bypass the limitations of the module system (or gradle's).++## Adding a library dependency++Lucene dependencies and their versions are managed globally using version catalogs (in `gradle/libs.versions.toml`)+<https://docs.gradle.org/current/userguide/platforms.html>.++Let's say we wish to add a dependency on library `foo.bar:baz` in version 1.2 to `:lucene:core`. Let's assume this+library is only used internally by the project. The `:lucene:core` project is configured by `lucene/core/build.gradle`,+so we add (or modify) the dependency block as follows:++```groovy+dependencies {+ moduleImplementation deps.baz+}+```++The `moduleImplementation` here is a named configuration explained in the section above. The `deps.baz` refers to the+version catalog named `deps`, in which the dependency `baz` should be declared. If this is the first reference to this+library, then we have to add it to `versions.toml` catalog: the version goes under the `versions` and module+coordinates under the `libraries` section:++```toml+[versions]+baz = "1.2"+...+[libraries]+baz = { module = "foo.bar:baz", version.ref = "baz" }+```++The version defined in the `versions` section is the preferred version of the library we wish to use. Finally, run+tidy to sort all entries in `libs.versions.toml`:++```bash+gradlew tidy+```++Gradle will try to consolidate different versions across different configurations to make sure they're compatible and+may complain if it encounters conflicting versions in the dependency tree. We want all dependencies to be consistent,+so we use an additional build plugin to ensure no accidental version changes occur. Whenever we add or remove+dependencies, we have to follow-up with lock file regeneration:++```bash+gradlew writeLocks+git diff versions.*+```++IMPORTANT: The `versions.lock` file will contain a list of actual library versions and configurations they occurred+in.++Once a new dependency is added it always makes sense to regenerate the lock file and look at which dependencies have+changed (and why).++## Inspecting current dependencies++The tree of dependencies of a project (in all configurations) can be dumped by the following command (example):++```bash+gradlew -p lucene/analysis/icu dependencies+```++But this can be a bit overwhelming; we will most likely be interested in just the "publicly visible" and+"classpath-visible" configurations.++The publicly visible project dependencies (classes shared by other modules importing our module) can be displayed+with:++```bash+gradlew -p lucene/analysis/icu dependencies --configuration moduleApi+```++And the "private" set of dependencies (real classpath) can be dumped with:++```bash+gradlew -p lucene/analysis/icu dependencies --configuration moduleRuntimePath+```++## Excluding a transitive dependency++Let's say `foo.bar:baz` has a transitive dependency on project `foo.bar:irrelevant` and we know the transitive+dependency is not crucial for the functioning of `foo.bar:baz`. We can exclude it by adding an exclusion block to the+original declaration:++```groovy+dependencies {+ implementation(deps.baz, {+ exclude group: "foo.bar", module: "irrelevant"+ })+}+```++Note the brackets - they are important and prevent accidental mistakes of applying the exclusion to the wrong scope.++## Updating dependency checksum and licenses++The last step is to make sure the licenses, notice files and checksums are in place for any new dependencies. This+command will print what's missing and where:++```bash+gradlew licenses+```++To update JAR checksums for licenses use:++```bash+gradlew writeChecksums+```diff --git a/help/dependencies.txt b/help/dependencies.txtdeleted file mode 100644index 144d6f45213..00000000000--- a/help/dependencies.txt+++ /dev/null@@ -1,137 +0,0 @@-Dependencies-============--Each gradle project can have multiple (named) "configurations"-and each configuration can have dependencies attached to it.--There are some standard conventions so, for example, the Java plugin-adds standard configurations such as "api", "implementation",-"testImplementation" and others. These configurations can also inherit-from each other; more about this topic can be found here:--https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html#dependency_management_for_java_projects-https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation-https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_plugin_and_dependency_management--Lucene uses the following configurations and attach project dependencies-to them:--moduleApi - makes the dependency available to main classes, tests and any- other modules importing the project (exportable dependency),--moduleImplementation - makes the dependency available to main classes, tests- but will *not* export the dependency to other modules (so their- compilation classpath won't contain it).--moduleTestImplementation - makes the dependency available for test classes only.--The "module" prefix is used to distinguish configurations which apply-to modular builds, compared to the regular classpath-configurations defined-by gradle's java module. Some Lucene modules may define regular classpath-entries to bypass the limitations of the module system (or gradle's).---Adding a library dependency------------------------------Lucene dependencies and their versions are managed globally using version-catalogs (in gradle/libs.versions.toml)-[https://docs.gradle.org/current/userguide/platforms.html].--Let's say we wish to add a dependency on library "foo.bar:baz" in-version 1.2 to :lucene:core. Let's assume this library is only-used internally by the project. The :lucene:core project is configured-by lucene/core/build.gradle, so we add (or modify) the dependency-block as follows:--dependencies {- moduleImplementation deps.baz-}--The "moduleImplementation" here is a named configuration explained in the-section above. The "deps.baz" refers to the version catalog named "deps",-in which the dependency "baz" should be declared. If this is the first-reference to this library, then we have to add it to "versions.toml" catalog:-the version goes under the "versions" and module coordinates-under the "libraries" section:--[versions]-baz = "1.2"-...-[libraries]-baz = { module = "foo.bar:baz", version.ref = "baz" }--The version defined in the "versions" section is the preferred version of the library-we wish to use. Finally, run tidy to sort all entries in libs.versions.toml:--gradlew tidy--Gradle will try to consolidate different versions across different-configurations to make sure they're compatible and may complain if it encounters-conflicting versions in the dependency tree. We want all dependencies to be consistent,-so we use an additional build plugin to ensure no accidental version changes-occur. Whenever we add or remove dependencies, we have to follow-up with lock file-regeneration:--gradlew writeLocks-git diff versions.*--IMPORTANT: The versions.lock file will contain a list of actual library versions-and configurations they occurred in.--Once a new dependency is added it always makes sense to regenerate the lock file-and look at which dependencies have changed (and why).---Inspecting current dependencies----------------------------------The tree of dependencies of a project (in all configurations) can-be dumped by the following command (example):--gradlew -p lucene\analysis\icu dependencies--But this can be a bit overwhelming; we will most likely be interested-in just the "publicly visible" and "classpath-visible" configurations.--The publicly visible project dependencies (classes shared by other-modules importing our module) can be displayed with:--gradlew -p lucene\analysis\icu dependencies --configuration moduleApi--And the "private" set of dependencies (real classpath) can be dumped-with:--gradlew -p lucene\analysis\icu dependencies --configuration moduleRuntimePath---Excluding a transitive dependency------------------------------------Let's say "foo.bar:baz" has a transitive dependency on project-"foo.bar:irrelevant" and we know the transitive dependency is not-crucial for the functioning of "foo.bar:baz". We can exclude it-by adding an exclusion block to the original declaration:--dependencies {- implementation(deps.baz, {- exclude group: "foo.bar", module: "irrelevant"- })-}--Note the brackets - they are important and prevent accidental-mistakes of applying the exclusion to the wrong scope.---Updating dependency checksum and licenses--------------------------------------------The last step is to make sure the licenses, notice files and checksums-are in place for any new dependencies. This command will print what's-missing and where:--gradlew licenses--To update JAR checksums for licenses use:--gradlew writeChecksumsdiff --git a/help/forbiddenApis.md b/help/forbiddenApis.mdnew file mode 100644index 00000000000..36d2b2d578a--- /dev/null+++ b/help/forbiddenApis.md@@ -0,0 +1,56 @@+# Forbidden API rules++Uwe's excellent forbidden API checker is applied as part of `check` task. The rules for each project are sourced+dynamically based on the actual set of dependencies of a project.++Signature files are under `gradle/validation/forbidden-apis` and are grouped into these three main categories:++```text+all/+main/+test/+```++and these extra exceptional ones:++```text+main-build-infra/+non-standard/+```++Signatures under `all/` are applied to all sources, `main/` are applied to all main source sets and `test/` to tests+only (and test fixtures, if any). `main-build-infra` is applied to gradle's build-infra project sources (build+plugins). `non-standard/` contains signature files applied selectively to just certain projects.++Let's say a project has a test dependency on an artifact called `foo.bar:baz`. An attempt would be made to load the+following signature files:++```text+all/defaults.txt+test/defaults.txt+test/foo.bar.baz.txt+```++From the above, only those files that actually exist are applied. You can verify which signature locations are+expected and which actually exist by running forbiddenApis tasks with info logger:++```bash+./gradlew -p lucene/analysis/morfologik forbiddenApis --info+```++## Example++Let's say we'd like to prevent people from using Guava's `com.google.common.base.Charsets` class. The rule would be:++```text+@defaultMessage Use java.nio.charset.StandardCharsets instead+com.google.common.base.Charsets+```++and we would place this rule in this file:++```text+gradle/validation/forbidden-apis/all/com.google.guava.guava.txt+```++From now on, if *any* module depends on this library, it will automatically pick up the signature file and enforce it.diff --git a/help/forbiddenApis.txt b/help/forbiddenApis.txtdeleted file mode 100644index 86e4e10ff86..00000000000--- a/help/forbiddenApis.txt+++ /dev/null@@ -1,54 +0,0 @@-Forbidden API rules-===================--Uwe's excellent forbidden API checker is applied as part of 'check'-task. The rules for each project are sourced dynamically based on the-actual set of dependencies of a project.--Signature files are under gradle/validation/forbidden-apis and are grouped-into these three main categories:--all/-main/-test/--and these extra exceptional ones:--main-build-infra/-non-standard/--Signatures under all/ are applied to all sources, main/ are applied to-all main source sets and test/ to tests only (and test fixtures, if any).-main-build-infra is applied to gradle's build-infra project sources (build-plugins). non-standard/ contains signature files applied selectively-to just certain projects.--Let's say a project has a test dependency on an artifact called "foo.bar:baz".-An attempt would be made to load the following signature files:--all/defaults.txt-test/defaults.txt-test/foo.bar.baz.txt--From the above, only those files that actually exist are applied. You can-verify which signature locations are expected and which actually-exist by running forbiddenApis tasks with info logger:--./gradlew -p lucene/analysis/morfologik forbiddenApis --info---Example----------Let's say we'd like to prevent people from using Guava's-com.google.common.base.Charsets class. The rule would be:--@defaultMessage Use java.nio.charset.StandardCharsets instead-com.google.common.base.Charsets--and we would place this rule in this file:--gradle/validation/forbidden-apis/all/com.google.guava.guava.txt--From now on, if *any* module depends on this library, it will-automatically pick up the signature file and enforce it.diff --git a/help/formatting.md b/help/formatting.mdnew file mode 100644index 00000000000..dfc3880f0e3--- /dev/null+++ b/help/formatting.md@@ -0,0 +1,40 @@+# Code formatting++Starting with (LUCENE-9564) Java code is enforced to comply with google-java-format conventions. In theory, you+shouldn't worry about what the convention actually looks like - write the code in any way you like and then run:++```bash+./gradlew tidy+```++prior to running your regular precommit checks. This will reformat your code so that it complies with the convention+and passes gradle `check` task.++IMPORTANT: wildcard imports are banned but google java format doesn't detect or fix this. There is a check for wildcard+imports implemented as a precommit check: you can run it via `uvx prek`. See `precommit.md` help file for detailed+instructions.++IMPORTANT: There is *no* way to mark sections of the code as excluded from formatting. This is by design and cannot be+altered. In the vast majority of cases the formatter will do a great job of cleaning up the code. Occasionally you may+want to rewrite the code (introduce a local variable or reshape code paths) so that it's easier to read after automatic+formatting.++## Other file formatting++CI is configured to run additional linting using eclint (<https://gitlab.com/greut/eclint>). This tool is optional. If+you'd like to run it locally on gradle's `check` task, install eclint locally and add this build option to+`build-options.local.properties`:++```properties+lucene.tool.eclint=eclint+```++A side effect of enabling eclint is that the `tidy` task will also attempt to fix offending eclint violations (if+possible).++## Gradle scripts++Groovy and gradle code is also automatically formatted and this formatting is enforced. This is unfortunately a heavy+download and runtime-costly application. If you'd like to temporarily skip this validation step, set the+`lucene.spotlessGradleScripts` option to false - either on command line using `-Plucene.spotlessGradleScripts=false`,+in your local `build-options.local.properties` or by any other means build options can be set.diff --git a/help/formatting.txt b/help/formatting.txtdeleted file mode 100644index bcd33b23fde..00000000000--- a/help/formatting.txt+++ /dev/null@@ -1,51 +0,0 @@-Code formatting-===============--Starting with (LUCENE-9564) Java code is enforced to comply with-google-java-format conventions. In theory, you shouldn't worry about-what the convention actually looks like - write the code in any way-you like and then run:--./gradlew tidy--prior to running your regular precommit checks. This will reformat-your code so that it complies with the convention and passes gradle-'check' task.--IMPORTANT: wildcard imports are banned but google java format doesn't-detect or fix this. There is a check for wildcard imports implemented-as a precommit check: you can run it via `uvx prek`. See precommit.txt-help file for detailed instructions.--IMPORTANT: There is *no* way to mark sections of the code as excluded-from formatting. This is by design and cannot be altered. In the vast-majority of cases the formatter will do a great job of cleaning up the-code. Occasionally you may want to rewrite the code (introduce a local-variable or reshape code paths) so that it's easier to read after-automatic formatting.---Other file formatting-=====================--CI is configured to run additional linting using eclint-(https://gitlab.com/greut/eclint). This tool is optional. If you'd like-to run it locally on gradle's 'check' task, install eclint locally and add-this build option to build-options.local.properties:--lucene.tool.eclint=eclint--A side effect of enabling eclint is that the 'tidy' task will also attempt-to fix offendling eclint violations (if possible).---Gradle scripts-==============--Groovy and gradle code is also automatically formatted and this formatting-is enforced. This is unfortunately a heavy download and runtime-costly-application. If you'd like to temporarily skip this validation step, set-the lucene.spotlessGradleScripts option to false - either on command line-using -Plucene.spotlessGradleScripts=false, in your local-build-options.local.properties or by any other means build options can be-set.diff --git a/help/git.md b/help/git.mdnew file mode 100644index 00000000000..0343bd44201--- /dev/null+++ b/help/git.md@@ -0,0 +1,17 @@+# git++A list of resources that may be helpful for those learning git:++- Dawid's task-oriented help: <https://github.com/dweiss/lucene-git-guides>+- git for computer scientists (a nice writeup on how git is essentially a graph of commits and labels attached to those commits): <https://eagain.net/articles/git-for-computer-scientists/>+- git pro (book): <https://git-scm.com/book/en/v2>+- git workflows, their pros and cons: <https://help.github.com/articles/what-is-a-good-git-workflow/>++## git blame++Git blame shows the last revision that touched a line in a given file. Certain reformatting commits may stand in the+way here. Please issue the following command so that git ignores those irrelevant commits:++```bash+git config blame.ignoreRevsFile .git-blame-ignore-revs+```diff --git a/help/git.txt b/help/git.txtdeleted file mode 100644index b17fffe8b62..00000000000--- a/help/git.txt+++ /dev/null@@ -1,27 +0,0 @@-git-===--A list of resources that may be helpful for those learning git:-- - Dawid's task-oriented help:- https://github.com/dweiss/lucene-git-guides-- - git for computer scientists (a nice writeup on how git is essentially a graph- of commits and labels attached to those commits):- https://eagain.net/articles/git-for-computer-scientists/-- - git pro (book)- https://git-scm.com/book/en/v2-- - git workflows, their pros and cons:- https://help.github.com/articles/what-is-a-good-git-workflow/---git blame-=========--Git blame shows the last revision that touched a line in a given file. Certain-reformatting commits may stand in the way here. Please issue the following-command so that git ignores those irrelevant commits:--git config blame.ignoreRevsFile .git-blame-ignore-revsdiff --git a/help/jmh.md b/help/jmh.mdnew file mode 100644index 00000000000..e43bdc7fc36--- /dev/null+++ b/help/jmh.md@@ -0,0 +1,76 @@+# Benchmarks++The `:lucene:benchmark-jmh` module can be used to compile and execute JMH (<https://github.com/openjdk/jmh>)+micro-benchmarks.++Look at existing classes and JMH documentation for inspiration on how to write good micro-benchmarks.++## Build++To compile the project and prepare JMH launcher, run:++```bash+gradlew :lucene:benchmark-jmh:assemble+```++The above target will display exact commands to execute JMH from command line.++## Run++```bash+java --module-path lucene/benchmark-jmh/build/benchmarks --module org.apache.lucene.benchmark.jmh+```++You can pass any JMH options to the above command, for example:++```text+-h displays verbose help for all options+-l list available benchmarks+-lp list benchmarks that pass the filter and their parameters+-prof perfasm use perfasm profiler to see assembly+-p size=1024 pass "size=1024" parameter to benchmark+regexp execute all benchmark containing regexp+```++Here is an example running a targeted benchmark:++```bash+java --module-path lucene/benchmark-jmh/build/benchmarks --module org.apache.lucene.benchmark.jmh VectorUtilBenchmark.binaryCosine -p size=1024+```++Or running all methods and sizes of VectorUtilBenchmark:++```bash+java --module-path lucene/benchmark-jmh/build/benchmarks --module org.apache.lucene.benchmark.jmh VectorUtilBenchmark+```++## hsdis setup++### Linux++In order to see disassembled instructions and not just binary instructions when using `-prof perfasm`:++```bash+git clone --depth 1 https://github.com/openjdk/jdk/+curl -f https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.gz | tar -zxf -+(cd jdk && bash ./configure --with-hsdis=binutils --with-binutils-src=../binutils-2.38 && make build-hsdis)+cp jdk/build/linux-x86_64-server-release/support/hsdis/hsdis-amd64.so $JAVA_HOME/lib/server+```++### Mac OS X++In order to see disassembled instructions and not just binary instructions when using `-prof dtraceasm`:++This one is a little rough because they removed the Makefile so you have to bring it back from the dead. Otherwise you+are stuck wrestling down full dependencies of OpenJDK (metal etc) just to compile a single C file. Also you must run+benchmarks as root to use dtrace, but it works.++```bash+git clone --depth 1 https://github.com/openjdk/jdk/+curl -f https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.gz | tar -zxf -+curl -fo jdk/src/utils/hsdis/binutils/Makefile https://raw.githubusercontent.com/openjdk/jdk/3c7ae1225f0d5575fd927a9b76fb40dc30e208cd/src/utils/hsdis/Makefile+vi jdk/src/utils/hsdis/binutils/Makefile # change SOURCE = hsdis.c to SOURCE = hsdis-binutils.c+vi jdk/src/utils/hsdis/binutils/hsdis-binutils.c # change #include "hsdis.h" to #include "../hsdis.h"+(cd jdk/src/utils/hsdis/binutils && make BINUTILS=../../../../../binutils-2.38 ARCH=aarch64)+cp jdk/src/utils/hsdis/binutils/build/macosx-aarch64/hsdis-aarch64.dylib $JAVA_HOME/lib/server+```diff --git a/help/jmh.txt b/help/jmh.txtdeleted file mode 100644index 84f904fe11c..00000000000--- a/help/jmh.txt+++ /dev/null@@ -1,69 +0,0 @@-benchmarks-==========--The :lucene:benchmark-jmh module contains can be used to compile-and execute JMH (https://github.com/openjdk/jmh) micro-benchmarks.--Look at existing classes and JMH documentation for inspiration on how-to write good micro-benchmarks.--build-=====--To compile the project and prepare JMH launcher, run:--gradlew :lucene:benchmark-jmh:assemble--The above target will display exact commands to execute JMH from-command line.--run-===--java --module-path lucene/benchmark-jmh/build/benchmarks --module org.apache.lucene.benchmark.jmh--You can pass any JMH options to the above command, for example:-- -h displays verbose help for all options- -l list available benchmarks- -lp list benchmarks that pass the filter and their parameters- -prof perfasm use perfasm profiler to see assembly- -p size=1024 pass "size=1024" parameter to benchmark- regexp execute all benchmark containing regexp--Here is an example running a targeted benchmark:--java --module-path lucene/benchmark-jmh/build/benchmarks --module org.apache.lucene.benchmark.jmh VectorUtilBenchmark.binaryCosine -p size=1024--Or running all methods and sizes of VectorUtilBenchmark--java --module-path lucene/benchmark-jmh/build/benchmarks --module org.apache.lucene.benchmark.jmh VectorUtilBenchmark---hsdis setup-===========--Linux--In order to see disassembled instructions and not just binary instructions when using '-prof perfasm':-- $ git clone --depth 1 https://github.com/openjdk/jdk/- $ curl -f https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.gz | tar -zxf -- $ (cd jdk && bash ./configure --with-hsdis=binutils --with-binutils-src=../binutils-2.38 && make build-hsdis)- $ cp jdk/build/linux-x86_64-server-release/support/hsdis/hsdis-amd64.so $JAVA_HOME/lib/server--Mac OS X--In order to see disassembled instructions and not just binary instructions when using '-prof dtraceasm':--This one is a little rough because they removed the Makefile so you have to bring it back from the dead.-Otherwise you are stuck wrestling down full dependencies of OpenJDK (metal etc) just to compile a single C file.-Also you must run benchmarks as root to use dtrace, but it works.-- $ git clone --depth 1 https://github.com/openjdk/jdk/- $ curl -f https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.gz | tar -zxf -- $ curl -fo jdk/src/utils/hsdis/binutils/Makefile https://raw.githubusercontent.com/openjdk/jdk/3c7ae1225f0d5575fd927a9b76fb40dc30e208cd/src/utils/hsdis/Makefile- $ vi jdk/src/utils/hsdis/binutils/Makefile, change SOURCE = hsdis.c to SOURCE = hsdis-binutils.c- $ vi jdk/src/utils/hsdis/binutils/hsdis-binutils.c, change #include "hsdis.h" to #include "../hsdis.h"- $ (cd jdk/src/utils/hsdis/binutils && make BINUTILS=../../../../../binutils-2.38 ARCH=aarch64)- $ cp jdk/src/utils/hsdis/binutils/build/macosx-aarch64/hsdis-aarch64.dylib $JAVA_HOME/lib/serverdiff --git a/help/jvms.md b/help/jvms.mdnew file mode 100644index 00000000000..5a29e17d41c--- /dev/null+++ b/help/jvms.md@@ -0,0 +1,17 @@+# Compiling and testing against different JVMs++By default tests are executed with the same Java Gradle is using internally.++To run tests against a different Java version, define a property called `runtime.java.home` or define an environment+variable `RUNTIME_JAVA_HOME` pointing at the JDK installation folder.++If property is being used, it can be a system property (`-D...`) or a project property (`-P...`).++Example:++```bash+gradlew test -p lucene/test-framework --tests TestJvmInfo -Dtests.verbose=true -Druntime.java.home=/jvms/jdk14+```++Note that an alternative JVM can also be made the "default" setting by adding it to (project-local)+`gradle.properties`.diff --git a/help/jvms.txt b/help/jvms.txtdeleted file mode 100644index 42a88d2c0b4..00000000000--- a/help/jvms.txt+++ /dev/null@@ -1,18 +0,0 @@-Compiling and testing against different JVMs-============================================--By default tests are executed with the same Java Gradle is using internally.--To run tests against a different Java version, define a property called-"runtime.java.home" or define an environment variable "RUNTIME_JAVA_HOME"-pointing at the JDK installation folder.--If property is being used, it can be a system property (-D...) or a project-property (-P...).--Example:--gradlew test -p lucene/test-framework --tests TestJvmInfo -Dtests.verbose=true -Druntime.java.home=/jvms/jdk14--Note that an alternative JVM can also be made the "default" setting-by adding it to (project-local) gradle.properties.diff --git a/help/localSettings.md b/help/localSettings.mdnew file mode 100644index 00000000000..0caab07ab00--- /dev/null+++ b/help/localSettings.md@@ -0,0 +1,35 @@+# Local gradle settings++The first invocation of any task in Lucene's gradle build will generate and save a project-local `gradle.properties`+file from a template, with some default gradle JVM settings, which you can modify to your needs.++See your `gradle.properties` file for more details of those settings.++## Build options++There are also various options that the Lucene build uses, which can affect how tests are run or enable additional+features (for example enable code coverage or profiling).++To see the current values of all these options, run:++```bash+./gradlew allOptions+```++this prints all build options for all modules. You can print all options for a single module too, for example:++```bash+./gradlew -p lucene/core buildOptions+```++The output of both tasks shows the options, their current values and their current value's "source". All build option+values can be overridden by, in order of priority:++- cli parameters to gradlew (system properties): `-DoptionKey=value`+- cli parameters to gradlew (gradle properties): `-PoptionKey=value`+- env variables: `optionKey=value ./gradlew ...`+- property file (local for you, non-versioned!): `build-options.local.properties`+- property file (versioned): `build-options.properties`++If you'd like to tweak some of the build options permanently, use the `build-options.local.properties` file. For+temporary overrides, use cli parameters (preferably gradle parameters `-Pxyz=value`).diff --git a/help/localSettings.txt b/help/localSettings.txtdeleted file mode 100644index 50089c81c1f..00000000000--- a/help/localSettings.txt+++ /dev/null@@ -1,39 +0,0 @@-Local gradle settings-=====================--The first invocation of any task in Lucene's gradle build will generate-and save a project-local 'gradle.properties' file from a template,-with some default gradle JVM settings, which you can modify to your needs.--See your 'gradle.properties' file for more details of those settings.---Build options-=============--There are also various options that the Lucene build uses, which can affect-how tests are run or enable additional features (for example enable code-coverage or profiling).--To see the current values of all these options, run:--./gradlew allOptions--this prints all build options for all modules. You can print all options-for a single module too, for example:--./gradlew -p lucene/core buildOptions--The output of both tasks shows the options, their current values-and their current value's "source". All build option values can be-overridden by, in order of priority:-- * cli parameters to gradlew (system properties): -DoptionKey=value- * cli parameters to gradlew (gradle properties): -PoptionKey=value- * env variables: optionKey=value ./gradlew ...- * property file (local for you, non-versioned!): build-options.local.properties- * property file (versioned): build-options.properties--If you'd like to tweak some of the build options permanently, use the-build-options.local.properties file. For temporary overrides, use-cli parameters (preferably gradle parameters -Pxyz=value).diff --git a/help/precommit.md b/help/precommit.mdnew file mode 100644index 00000000000..23ab4c0784a--- /dev/null+++ b/help/precommit.md@@ -0,0 +1,32 @@+# Precommit checks++Precommit checks are run by CI on your pull request.++Checks use the prek tool:++- src: <https://github.com/j178/prek>+- docs: <https://prek.j178.dev/>++To run checks automatically before committing:++```bash+uvx prek+```++To install a precommit hook so this happens automatically:++```bash+uv tool install prek+prek install --allow-missing-config+```++Please note: The `--allow-missing-config` option is only required if you intend to also work on older release+branches that do not yet have support for prek.++To exhaustively force-check all files (like CI does):++```bash+uvx prek --all-files+```++You need the uv package manager: <https://docs.astral.sh/uv/getting-started/installation/>diff --git a/help/precommit.txt b/help/precommit.txtdeleted file mode 100644index b9577aa472e..00000000000--- a/help/precommit.txt+++ /dev/null@@ -1,27 +0,0 @@-Precommit Checks-================--Precommit checks are run by CI on your pull request.--Checks use the prek tool:- * src: https://github.com/j178/prek- * docs: https://prek.j178.dev/--To run checks automatically before committing:--uvx prek--To install a precommit hook so this happens automatically:--uv tool install prek-prek install --allow-missing-config--Please note: The "--allow-missing-config" option is only required if you-intend to also work on older release branches that do not yet have support-for prek.--To exhaustively force-check all files (like CI does):--uvx prek --all-files--You need the uv package manager: https://docs.astral.sh/uv/getting-started/installation/diff --git a/help/publishing.md b/help/publishing.mdnew file mode 100644index 00000000000..f7da20fc4c4--- /dev/null+++ b/help/publishing.md@@ -0,0 +1,154 @@+# Distribution and artifact publishing++See all distribution-related tasks by running:++```bash+gradlew tasks --group distribution+```++## Maven++To publish Lucene Maven artifacts to a local `~/.m2` repository, run:++```bash+gradlew mavenToLocal+```++To publish Lucene Maven artifacts to Apache repositories (CI or release manager's job, typically!), run:++```bash+gradlew mavenToApacheSnapshots -PasfNexusUsername= -PasfNexusPassword=+gradlew mavenToApacheReleases -PasfNexusUsername= -PasfNexusPassword= [optional signing options]+```++See artifact signing section below if you plan to use `mavenToApacheReleases`.++It is a good idea to avoid passing passwords on command line. CI jobs have these properties saved in+`~/.gradle/gradle.properties` - this way they are read automatically.++Apache Releases repository will not accept snapshots.++## Release (distribution) artifacts++To collect all release artifacts, and optionally sign them, run:++```bash+gradlew assembleRelease [optional signing options]+```++All distribution artifacts will be placed under:++```text+lucene/distribution/build/release+```++Artifact signing is optional (but required if you're really making a release).++## Artifact signing++Certain tasks may optionally sign artifacts or require artifacts to be signed:++- `assembleRelease`+- `mavenToApacheReleases`++Signing can be enabled by adding the `-Psign` option, for example:++```bash+gradlew assembleRelease mavenToApacheReleases -Psign+```++By default, gradle uses a Java-based implementation of PGP for signing, which requires several `signing.*` properties+via either `~/.gradle/gradle.properties` or command-line options:++<https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials>++An example full command-line that assembles signed artifacts could look like this:++```bash+gradlew assembleRelease mavenToApacheReleases -Psign -Psigning.keyId=... -Psigning.password=... -Psigning.secretKeyRingFile=...+```++The keyId is the last 8 digits of your key (`gpg -k` will print your keys). Gradle documentation has more options of+secure passing of private key information and passwords.++## Artifact signing using an external GPG with GPG Agent++You can use an external GPG command to deal with signing artifacts, without needing to give gradle your passphrase, by+adding a `-PuseGpg=true` option, but this changes the properties you must specify:++For gpg2:++```bash+gradlew [tasks] -Psign -PuseGpg=true -Psigning.gnupg.keyName=...+```++For gpg:++```bash+gradlew [tasks] -Psign -PuseGpg=true -Psigning.gnupg.keyName=... -Psigning.gnupg.useLegacyGpg=true+```++The keyName is the last 8 digits of your key (`gpg -k` will print your keys).++There are additional (optional) `signing.gnupg.*` properties which exist that may be useful/necessary in your system:++```properties+# Changes the default executable from `gpg2` to `gpg` and explicitly sets `--use-agent`+signing.gnupg.useLegacyGpg=true++# Allows explicit control over what command executable used (ex: `gpg2`, `gpg`, `gpg.exe`, etc...)+signing.gnupg.executable=gpg++# Overrides GnuPG's default home directory (ex: `~/.gnupg/`)+signing.gnupg.homeDir=/tmp/gnupg-home++# Overrides GnuPG's default configuration file+signing.gnupg.optionsFile=/tmp/gnupg-home/my.conf++# Provide your passphrase to gradle to hand off to gpg. *NOT RECOMMENDED*, see below.+signing.gnupg.passphrase=...+```++If in doubt, consult gradle's signing plugin documentation:+<https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent>++`signing.gnupg.passphrase` is not recommended because there is no advantage to using an external GPG process if you+use it. If you are comfortable giving gradle your passphrase, then there is no reason to use an external GPG process+via `-PuseGpg=true`. Just use the `signing.*` options described previously to let gradle deal with your key directly.++Because of how Gradle's signing plugin invokes GPG, using an external GPG process *only* works if your GPG+configuration uses a GPG agent (required by gpg2) and if the "pinentry" for your GPG agent does not require access to+the tty to prompt you for a password.++If the following command fails with your GPG configuration, you can not use an external GPG process with gradle:++```bash+echo foo | gpg --batch --no-tty --armor --detach-sign --use-agent --local-user YOUR_KEY_NAME+```++## Notes about GPG error messages++### `gpg: signing failed: Inappropriate ioctl for device` or `Invalid IPC response`++This typically happens if your `gpg-agent` is configured (either globally for your operating system, or personally in+your `~/.gnupg/gpg-agent.conf`) to use a `pinentry` command which depends on using the same `tty` as the `gpg` command+(ex: `pinentry-curses`, or `pinentry-tty`, etc...).++`tty` based `pinentry` implementations do not work when Gradle's signing plugin is attempting to invoke `gpg` -- among+other problems: Gradle is multi-threaded and we sign multiple artifacts by default. Even if you use `--max-workers 1`+to force single-threaded execution, the signing plugin invokes gpg with `--batch --no-tty`, making it impossible for+gpg (or a tty based pinentry) to prompt you for your passphrase in the same terminal where you run Gradle.++Developers are encouraged to configure a *non* `tty` based `pinentry` (ex: `pinentry-gnome`, `pinentry-x11`,+`pinentry-qt`, `pinentry-mac`, `pinentry-wsl-ps1`, etc...) either globally in your operating system, or personally in+your `~/.gnupg/gpg-agent.conf`, or in a new `gpg-agent.conf` file a new GnuPG configuration directory (containing a+copy of your private keys) that you direct gradle to via `signing.gnupg.homeDir`++If this is not possible, then you should avoid using an external GPG process, and use the default (pure java) Artifact+signing support++### `gpg: signing failed: No such file or directory`++This may mean that there is a problem preventing `gpg` from communicating correctly with the `gpg-agent` (and/or+invoking your `pinentry` program) that is independent of gradle. Try running `pkill gpg-agent` and then retrying your+`./gradlew` commanddiff --git a/help/publishing.txt b/help/publishing.txtdeleted file mode 100644index 38c809497a3..00000000000--- a/help/publishing.txt+++ /dev/null@@ -1,132 +0,0 @@-Distribution and artifact publishing-====================================---See all distribution-related tasks by running:-gradlew tasks --group distribution---Maven--------To publish Lucene Maven artifacts to a local ~/.m2 repository, run:--gradlew mavenToLocal--To publish Lucene Maven artifacts to Apache repositories-(CI or release manager's job, typically!), run:--gradlew mavenToApacheSnapshots -PasfNexusUsername= -PasfNexusPassword=-gradlew mavenToApacheReleases -PasfNexusUsername= -PasfNexusPassword= [optional signing options]--See artifact signing section below if you plan to use mavenToApacheReleases.--It is a good idea to avoid passing passwords on command line. CI jobs have-these properties saved in ~/.gradle/gradle.properties - this way they-are read automatically.--Apache Releases repository will not accept snapshots.---Release (distribution) artifacts-----------------------------------To collect all release artifacts, and optionally sign them, run:--gradlew assembleRelease [optional signing options]--All distribution artifacts will be placed under:--lucene/distribution/build/release--Artifact signing is optional (but required if you're really making a release).---Artifact signing-------------------Certain tasks may optionally sign artifacts or require artifacts to be signed:-- assembleRelease- mavenToApacheReleases--Signing can be enabled by adding the "-Psign" option, for example:--gradlew assembleRelease mavenToApacheReleases -Psign--By default, gradle uses a Java-based implementation of PGP for signing, which requires-several "signing.*" properties via either ~/.gradle/gradle.properties or command-line options:--https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials--An example full command-line that assembles signed artifacts could look like this:--gradlew assembleRelease mavenToApacheReleases -Psign -Psigning.keyId=... -Psigning.password=... -Psigning.secretKeyRingFile=...--The keyId is the last 8 digits of your key (gpg -k will print your keys). Gradle documentation has more options-of secure passing of private key information and passwords.---Artifact signing using an external GPG with GPG Agent--------------------------------------------------------You can use an external GPG command to deal with signing artifacts, without needing to give gradle your passphrase,-by adding a "-PuseGpg=true" option, but this changes the properties you must specify:--For gpg2:-gradlew [tasks] -Psign -PuseGpg=true -Psigning.gnupg.keyName=...--For gpg:-gradlew [tasks] -Psign -PuseGpg=true -Psigning.gnupg.keyName=... -Psigning.gnupg.useLegacyGpg=true--The keyName is the last 8 digits of your key (gpg -k will print your keys).--There are additional (optional) "signing.gnupg.*" properties which exist that may be useful/necessary in your system:--signing.gnupg.useLegacyGpg=true # Changes the default executable from `gpg2` to `gpg` and explicitly sets `--use-agent`-signing.gnupg.executable=gpg # Allows explicit control over what command executable used (ex: `gpg2`, `gpg`, `gpg.exe`, etc...)-signing.gnupg.homeDir=/tmp/gnupg-home # overrides GnuPG's default home directory (ex: `~/.gnupg/`)-signing.gnupg.optionsFile=/tmp/gnupg-home/my.conf # overrides GnuPG's default configuration file-signing.gnupg.passphrase=... # Provide your passphrase to gradle to hand off to gpg. *NOT RECOMMENDED*, see below.--If in doubt, consult gradle's signing plugin documentation:-https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent--"signing.gnupg.passphrase" is not recommended because there is no advantage to using an external GPG process if you use it.-If you are comfortable giving gradle your passphrase, then there is no reason to use an external GPG process via '-PuseGpg=true'.-Just use the "signing.*" options described previously to let gradle deal with your key directly.--Because of how Gradle's signing plugin invokes GPG, using an external GPG process *only* works if your GPG configuration uses a-GPG agent (required by gpg2) and if the "pinentry" for your GPG agent does not require access to the tty to prompt you for a password.--If the following command fails with your GPG configuration, you can not use an external GPG process with gradle:--echo foo | gpg --batch --no-tty --armor --detach-sign --use-agent --local-user YOUR_KEY_NAME---Notes About GPG Error Messages---------------------------------### `gpg: signing failed: Inappropriate ioctl for device` or `Invalid IPC response`--This typically happens if your `gpg-agent` is configured (either globally for your operating system, or personally in your-`~/.gnupg/gpg-agent.conf`) to use a `pinentry` command which depends on using the same `tty` as the `gpg` command (ex: `pinentry-curses`,-or `pinentry-tty`, etc...).--`tty` based `pinentry` implementations do not work when Gradle's signing plugin is attempting to invoke `gpg` -- among other problems:-Gradle is multi-threaded and we sign multiple artifacts by default. Even if you use "--max-workers 1" to force single-threaded execution,-the signing plugin invokes gpg with `--batch --no-tty`, making it impossible for gpg (or a tty based pinentry) to prompt you for your passphrase-in the same terminal where you run Gradle.--Developers are encouraged to configure a *non* `tty` based `pinentry` (ex: `pinentry-gnome`, `pinentry-x11`, `pinentry-qt`, `pinentry-mac`,-`pinentry-wsl-ps1`, etc...) either globally in your operating system, or personally in your `~/.gnupg/gpg-agent.conf`, or in a new-`gpg-agent.conf` file a new GnuPG configuration directory (containing a copy of your private keys) that you direct gradle to via-`signing.gnupg.homeDir`--If this is not possible, then you should avoid using an external GPG process, and use the default (pure java) Artifact signing support---### `gpg: signing failed: No such file or directory`--This may mean that there is a problem preventing `gpg` from communicating correctly with the `gpg-agent` (and/or invoking your `pinentry`-program) that is independent of gradle. Try running `pkill gpg-agent` and then retrying your `./gradlew` commanddiff --git a/help/regeneration.md b/help/regeneration.mdnew file mode 100644index 00000000000..fef1c94c5c3--- /dev/null+++ b/help/regeneration.md@@ -0,0 +1,157 @@+# Regeneration++Lucene has a number of machine-generated resources - some of these are resource (binary) files, others are Java source+files that are stored (and compiled) with the rest of Lucene source code.++If you're reading this, chances are that:++1. you've hit a build check error that said you've modified a generated resource and some checksums are out of sync.+2. you need to regenerate one (or more) of these resources because of third party library updates or other reasons.++In many cases hitting (1) means you'll have to do (2) so let's discuss these in order.++## Checksum validation errors++LUCENE-9868 introduced a system of storing (and validating) checksums of generated files so that they are not+accidentally modified. This checksum-checking system will fail the build with a message similar to this one:++```text+Execution failed for task ':lucene:core:regenerateStandardTokenizerChecksumCheck'.+> Checksums mismatch for generated resources; you might have modified a generated resource (regenerate task: regenerateStandardTokenizer, checksum file: .../lucene/core/src/generated/checksums/regenerateStandardTokenizer.json).++ Current checksums:+ - lucene/core/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.java=f4d6311e03a97cb55301cfa55fab3338b1fdb725++ Expected checksums:+ - lucene/core/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.java=f4d6311e03a97cb55301cfa55fab3338b1fdb724++ Input files for this task are:+ - .../lucene/core/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.jflex+ - .../lucene/gradle/regenerate/jflex/skeleton.disable.buffer.expansion.txt++ Files generated by this task are:+ - .../lucene/core/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.java+```++The message shows you which resources have mismatches on checksums (in this case `StandardTokenizerImpl.java`) but+also the *module* where the generated resource exists, the *task name* that should be used to regenerate this resource+and the inputs and outputs of that task:++```text+:lucene:core:regenerateStandardTokenizer+```++To resolve the problem, try to `git diff` the changes that caused the build failure (to see why the checksums have+changed). Then decide if the change was accidental or intentional and either:++1. revert any accidental changes made to inputs/outputs of generated resources,+2. regenerate the derived resources, possibly saving new checksums.++If you decide to regenerate, just running the task hinted at in the error message should work fine, for example:++```bash+gradlew :lucene:core:regenerateStandardTokenizer+```++This regenerates all resources the task `generateStandardTokenizer` produces and updates the corresponding checksums.+If you want to bypass any of gradle's smart up-to-date checks and force regeneration, use the standard gradle's switch:++```bash+gradlew :lucene:core:regenerateStandardTokenizer --rerun-tasks+```++## Resource regeneration++Lucene's "convention" task for regenerating all derived resources in a given module is called `regenerate` and you can+apply it to all Lucene modules at once by running:++```bash+gradlew regenerate+```++It is typically much wiser to limit the scope of regeneration to only the module you're working with though:++```bash+gradlew -p lucene/analysis/common regenerate+```++If you're interested in what specific generation tasks are available, see the task list for the generation group:++```bash+gradlew tasks --group regeneration+```++or limit the output to a particular module:++```bash+gradlew -p lucene/analysis/common tasks --group regeneration+```++which displays (at the moment of writing):++```text+regenerate - Rerun any code or static data generation tasks.+regenerateClassicTokenizer - Regenerate ClassicTokenizerImpl.java+regenerateHTMLCharacterEntities - Regenerate HTMLCharacterEntities.jflex+regenerateHTMLStripCharFilter - Regenerate HTMLStripCharFilter.java+regenerateTlds - Regenerate top-level domain jflex macros and tests+regenerateUAX29URLEmailTokenizer - Regenerate UAX29URLEmailTokenizerImpl.java+regenerateUnicodeProps - Regenerate UnicodeProps.java using ICU+regenerateWikipediaTokenizer - Regenerate WikipediaTokenizerImpl.java+```++## Resource checksums, incremental generation and advanced topics++Many resource generation tasks require specific tools (perl, python, bash shell) and resources that may not be+available on all platforms. In LUCENE-9868 we tried to make resource generation tasks "incremental" so that they only+run if their sources (or outputs) have changed. So if you run the generic `regenerate` task, many of the actual+regeneration sub-tasks will be "skipped" - you can see this if you run gradle with plain console, for example:++```bash+gradlew -p lucene/analysis/common regenerate --console=plain+```++```text+...+> Task :lucene:analysis:common:regenerateUnicodeProps SKIPPED+> Task :lucene:analysis:common:regenerateUAX29URLEmailTokenizer SKIPPED+...+```++This shouldn't worry you at all - the internal tasks are skipped because the inputs and outputs of these task are up+to date. If changes were detected, the task would be re-executed, followed by any necessary cleanup tasks (like code+formatting).++Sometimes you may want to *force* the regeneration task to run, even if the checksums indicate nothing has changed.+This may happen if you're paranoid or don't trust gradle (and there's no reason you should).++If you want to force-run the regeneration, use gradle's `--rerun-tasks` option:++```bash+gradlew regenerate --rerun-tasks+```++Scoping the call to a particular module will also work:++```bash+gradlew -p lucene/analysis/common regenerate --rerun-tasks+```++Scoping the call to a particular task will also work:++```bash+gradlew -p lucene/analysis/common regenerateUnicodeProps --rerun-tasks+```++Finally, if you do feel like force-regenerating everything, remember to exclude this monster (it takes quite a long+time and requires significant heap memory)...++```bash+gradlew regenerate -x regenerateUAX29URLEmailTokenizer --rerun-tasks+```++and on Windows, exclude snowball regeneration (requires bash):++```bash+gradlew regenerate -x regenerateUAX29URLEmailTokenizer -x snowball --rerun-tasks+```diff --git a/help/regeneration.txt b/help/regeneration.txtdeleted file mode 100644index 27bb855a4ae..00000000000--- a/help/regeneration.txt+++ /dev/null@@ -1,149 +0,0 @@-Regeneration-============--Lucene has a number of machine-generated resources - some of these are-resource (binary) files, others are Java source files that are stored-(and compiled) with the rest of Lucene source code.--If you're reading this, chances are that:--1) you've hit a build check error that said you've modified a generated- resource and some checksums are out of sync.--2) you need to regenerate one (or more) of these resources because of- third party library updates or other reasons.--In many cases hitting (1) means you'll have to do (2) so let's discuss-these in order.---Checksum validation errors-----------------------------LUCENE-9868 introduced a system of storing (and validating) checksums of-generated files so that they are not accidentally modified. This checksum-checking-system will fail the build with a message similar to this one:--Execution failed for task ':lucene:core:regenerateStandardTokenizerChecksumCheck'.-> Checksums mismatch for generated resources; you might have modified a generated resource (regenerate task: regenerateStandardTokenizer, checksum file: .../lucene/core/src/generated/checksums/regenerateStandardTokenizer.json).-- Current checksums:- - lucene/core/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.java=f4d6311e03a97cb55301cfa55fab3338b1fdb725-- Expected checksums:- - lucene/core/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.java=f4d6311e03a97cb55301cfa55fab3338b1fdb724-- Input files for this task are:- - .../lucene/core/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.jflex- - .../lucene/gradle/regenerate/jflex/skeleton.disable.buffer.expansion.txt-- Files generated by this task are:- - .../lucene/core/src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.java--The message shows you which resources have mismatches on checksums (in this case-StandardTokenizerImpl.java) but also the *module* where the generated-resource exists, the *task name* that should be used to regenerate this resource-and the inputs and outputs of that task:--:lucene:core:regenerateStandardTokenizer--To resolve the problem, try to "git diff" the changes that caused the build failure-(to see why the checksums have changed). Then decide if the change was accidental-or intentional and either:--1) revert any accidental changes made to inputs/outputs of generated resources,--2) regenerate the derived resources, possibly saving new checksums.--If you decide to regenerate, just running the task hinted at in the error message-should work fine, for example:--gradlew :lucene:core:regenerateStandardTokenizer--This regenerates all resources the task "generateStandardTokenizer" produces-and updates the corresponding checksums. If you want to bypass any of gradle's-smart up-to-date checks and force regeneration, use the standard gradle's switch:--gradlew :lucene:core:regenerateStandardTokenizer --rerun-tasks---Resource regeneration------------------------Lucene's "convention" task for regenerating all derived resources in a given-module is called "regenerate" and you can apply it to all Lucene modules at-once by running:--gradlew regenerate--It is typically much wiser to limit the scope of regeneration to only-the module you're working with though:--gradlew -p lucene/analysis/common regenerate--If you're interested in what specific generation tasks are available, see-the task list for the generation group:--gradlew tasks --group regeneration--or limit the output to a particular module:--gradlew -p lucene/analysis/common tasks --group regeneration--which displays (at the moment of writing):--regenerate - Rerun any code or static data generation tasks.-regenerateClassicTokenizer - Regenerate ClassicTokenizerImpl.java-regenerateHTMLCharacterEntities - Regenerate HTMLCharacterEntities.jflex-regenerateHTMLStripCharFilter - Regenerate HTMLStripCharFilter.java-regenerateTlds - Regenerate top-level domain jflex macros and tests-regenerateUAX29URLEmailTokenizer - Regenerate UAX29URLEmailTokenizerImpl.java-regenerateUnicodeProps - Regenerate UnicodeProps.java using ICU-regenerateWikipediaTokenizer - Regenerate WikipediaTokenizerImpl.java---Resource checksums, incremental generation and advanced topics-----------------------------------------------------------------Many resource generation tasks require specific tools (perl, python, bash shell)-and resources that may not be available on all platforms. In LUCENE-9868 we tried-to make resource generation tasks "incremental" so that they only run if their-sources (or outputs) have changed. So if you run the generic "regenerate" task, many of the-actual regeneration sub-tasks will be "skipped" - you can see this if you run gradle with-plain console, for example:--gradlew -p lucene/analysis/common regenerate --console=plain--...-> Task :lucene:analysis:common:regenerateUnicodeProps SKIPPED-> Task :lucene:analysis:common:regenerateUAX29URLEmailTokenizer SKIPPED-...--This shouldn't worry you at all - the internal tasks are skipped because-the inputs and outputs of these task are up to date. If changes were detected, the task-would be re-executed, followed by any necessary cleanup tasks (like code formatting).--Sometimes you may want to *force* the regeneration task to run, even if the-checksums indicate nothing has changed. This may happen if you're paranoid or don't trust-gradle (and there's no reason you should).--If you want to force-run the regeneration, use gradle's "--rerun-tasks" option:--gradlew regenerate --rerun-tasks--Scoping the call to a particular module will also work:--gradlew -p lucene/analysis/common regenerate --rerun-tasks--Scoping the call to a particular task will also work:--gradlew -p lucene/analysis/common regenerateUnicodeProps --rerun-tasks--Finally, if you do feel like force-regenerating everything, remember to exclude this-monster (it takes quite a long time and requires significant heap memory)...--gradlew regenerate -x regenerateUAX29URLEmailTokenizer --rerun-tasks--and on Windows, exclude snowball regeneration (requires bash):--gradlew regenerate -x regenerateUAX29URLEmailTokenizer -x snowball --rerun-tasksdiff --git a/help/tests.md b/help/tests.mdnew file mode 100644index 00000000000..46a6041619d--- /dev/null+++ b/help/tests.md@@ -0,0 +1,241 @@+# Testing++Examples below assume cwd at the gradlew script in the top directory of the project's checkout.++## Generic test/ checkup commands++Run all unit tests:++```bash+gradlew test+```++Run all(\*) verification tasks, including tests:++```bash+gradlew check+```++(\*) This step may omit certain validation tasks (errorprone, for example) that are slow or require external+resources. A pull request runs all those locally omitted tasks on the CI (jenkins, gh actions). For this reason, it's+a good idea to run patches via the CI.++Run all verification tasks, excluding tests (`-x` is gradle's generic task exclusion mechanism):++```bash+gradlew check -x test+```++Run verification for a selected module only:++```bash+gradlew :lucene:core:check # By full gradle project path+gradlew -p lucene/core check # By folder designation + task+```++## Randomization++To run tests with the given starting seed pass `tests.seed` property:++```bash+gradlew :lucene:misc:test -Ptests.seed=DEADBEEF+```++There are a lot of other test randomization properties available. To list them, their defaults and current values run+the `buildOptions` task against a project that has tests. For example:++```bash+gradlew -p lucene/core buildOptions+```++or list all options with:++```bash+gradlew allOptions+```++## Filtering++Run tests of lucene-core module:++```bash+gradlew -p lucene/core test+```++Run a single test case (from a single module). Uses gradle's built-in filtering+(<https://docs.gradle.org/current/userguide/java_testing.html#test_filtering>):++```bash+gradlew -p lucene/core test --tests TestDemo+```++Run all tests in a package:++```bash+gradlew -p lucene/core test --tests "org.apache.lucene.document.*"+```++Run all test classes/ methods that match this pattern:++```bash+gradlew -p lucene/core test --tests "*testFeatureMissing*"+```++## Test groups++Tests can be filtered by an annotation they're marked with. Some test group annotations include: `@AwaitsFix`,+`@Nightly`++This uses filtering infrastructure on the *runner* (randomizedtesting), not gradle's built-in mechanisms (but it can be+combined with `--tests`). For example, run all lucene-core tests annotated as `@Nightly`:++```bash+gradlew -p lucene/core test -Ptests.filter=@Nightly+```++Test group filters can be combined into Boolean expressions:++```bash+gradlew -p lucene/core test "default and not(@awaitsfix or @nightly)"+```++## Reiteration ("beasting")++Multiply each test case N times (this works by repeating the same test within the same JVM; it also works in IDEs):++```bash+gradlew -p lucene/core test --tests TestDemo -Ptests.iters=5+```++Tests tasks will be (by default) re-executed on each invocation because we pick a random global `tests.seed` and+because we want them to (force the test task to run). If you want to make the `tests` task obey up-to-date gradle+rules, fix the seed and force rerunning:++```bash+gradlew -p lucene/core test -Ptests.seed=deadbeef -Ptests.rerun=true+```++These properties can be set in your local `gradle.properties`. To force re-execution of tests, even for the same master+seed, apply `cleanTest` task:++```bash+gradlew -p lucene/core cleanTest test -Ptests.seed=deadbeef+```++The `tests.iters` option should be sufficient for individual test cases and is *much* faster than trying to duplicate+re-runs of the entire test suites. When it is absolutely needed to re-run an entire suite (because of randomization in+the static initialization, for example), you can do it by running the `beast` task with `tests.dups` option:++```bash+gradlew -p lucene/core beast -Ptests.dups=10 --tests TestPerFieldDocValuesFormat+```++Note the filter (`--tests`) used to narrow down test reiterations to a particular class. You can use any filter,+including no filter at all, but it rarely makes sense (will take ages). By default the test tasks generated by the+`beast` mode use a random starting seed for randomization. If you pass an explicit seed, this won't be the case (all+tasks will use exactly the same starting seed):++```bash+gradlew -p lucene/core beast -Ptests.dups=10 --tests TestPerFieldDocValuesFormat -Dtests.seed=deadbeef+```++## Verbose mode and debugging++The `tests.verbose` mode switch enables standard streams from tests to be dumped directly to the console. Run your+verbose tests explicitly specifying the project and test task or a fully qualified task path. Example:++```bash+gradlew -p lucene/core test -Ptests.verbose=true --tests "TestDemo"+```++## Larger heap size++By default tests run with a 512 MB max heap. But some tests (monster/nightly) need more heap. Use `-Ptests.heapsize`+for this:++```bash+gradlew -p lucene/core test --tests "Test2BFST" -Ptests.heapsize=32g+```++## Run GUI tests headlessly with Xvfb (Linux only)++GUI test for Luke application launches a window, this might mess up your monitor depending on the display manager you+are using. In that case, you can install Xvfb (X Virtual Frame Buffer) so that the test runs on the virtual display+and does not open a real window.++```bash+# redhat-type OS+sudo yum install Xvfb++# ubuntu/debian-type OS+sudo apt install xvfb++# arch+sudo pacman -S xorg-server-xvfb+```++## Profiling slow tests++The `tests.profile` mode switch turns on a sampling profiler during test execution, and prints a simple summary at the+end.++For example, top-10 histogram of methods (cpu samples):++```bash+gradlew -p lucene/core test -Ptests.profile=true+```++Alternatively, you can profile heap allocations instead:++```bash+gradlew -p lucene/core test -Ptests.profile=true -Ptests.profile.mode=heap+```++By default, results are computed (deduplicated) on just the method name, folding together all events from the same+method. To drill down further, you can increase the stack size from the default of 1, to get a histogram of+stacktraces instead:++```bash+gradlew -p lucene/core test -Ptests.profile=true -Ptests.profile.stacksize=8+```++For big methods, it can also be helpful to include line numbers for more granularity:++```bash+gradlew -p lucene/core test -Ptests.profile=true -Ptests.profile.linenumbers=true+```++Using these additional options will make the results more sparse, so it may be useful to increase the top-N count:++```bash+gradlew -p lucene/core test -Ptests.profile=true -Ptests.profile.count=100+```++## Generating coverage reports++Running the `coverage` task (or setting the property `tests.coverage` to true) will run the tests with instrumentation+to record code coverage.++Example:++```bash+gradlew -p lucene/core coverage+open lucene/core/build/reports/jacoco/test/html/index.html+```++If you want to use test filtering to just check a particular test, specify the `test` task explicitly before+`coverage`:++```bash+gradlew -p lucene/core test --tests TestDemo coverage+open lucene/core/build/reports/jacoco/test/html/index.html+```++## External data sets++Some tests may require external (and large) data sets. To see relevant tasks that download and extract these data+files automatically, run the following:++```bash+gradlew tasks --group "Data set download"+```diff --git a/help/tests.txt b/help/tests.txtdeleted file mode 100644index ab7c6ffb431..00000000000--- a/help/tests.txt+++ /dev/null@@ -1,221 +0,0 @@-Testing-=======--Examples below assume cwd at the gradlew script in the top directory of-the project's checkout.---Generic test/ checkup commands---------------------------------Run all unit tests:--gradlew test--Run all(*) verification tasks, including tests:--gradlew check--(*) This step may omit certain validation tasks (errorprone, for example)- that are slow or require external resources. A pull request runs all- those locally omitted tasks on the CI (jenkins, gh actions).- For this reason, it's a good idea to run patches via the CI.--Run all verification tasks, excluding tests (-x is gradle's generic task-exclusion mechanism):--gradlew check -x test--Run verification for a selected module only:--gradlew :lucene:core:check # By full gradle project path-gradlew -p lucene/core check # By folder designation + task---Randomization----------------To run tests with the given starting seed pass 'tests.seed'-property:--gradlew :lucene:misc:test -Ptests.seed=DEADBEEF--There are a lot of other test randomization properties-available. To list them, their defaults and current values-run the 'buildOptions' task against a project that has tests.-For example:--gradlew -p lucene/core buildOptions--or list all options with:--gradlew allOptions---Filtering------------Run tests of lucene-core module:--gradlew -p lucene/core test--Run a single test case (from a single module). Uses gradle's built-in filtering-(https://docs.gradle.org/current/userguide/java_testing.html#test_filtering):--gradlew -p lucene/core test --tests TestDemo--Run all tests in a package:--gradlew -p lucene/core test --tests "org.apache.lucene.document.*"--Run all test classes/ methods that match this pattern:--gradlew -p lucene/core test --tests "*testFeatureMissing*"---Test groups--------------Tests can be filtered by an annotation they're marked with.-Some test group annotations include: @AwaitsFix, @Nightly--This uses filtering infrastructure on the *runner* (randomizedtesting),-not gradle's built-in mechanisms (but it can be combined with "--tests").-For example, run all lucene-core tests annotated as @Nightly:--gradlew -p lucene/core test -Ptests.filter=@Nightly--Test group filters can be combined into Boolean expressions:--gradlew -p lucene/core test "default and not(@awaitsfix or @nightly)"---Reiteration ("beasting")---------------------------Multiply each test case N times (this works by repeating the same test-within the same JVM; it also works in IDEs):--gradlew -p lucene/core test --tests TestDemo -Ptests.iters=5--Tests tasks will be (by default) re-executed on each invocation because-we pick a random global tests.seed and because we want them to (force-the test task to run). If you want to make the 'tests' task obey up-to-date-gradle rules, fix the seed and force rerunning:--gradlew -p lucene/core test -Ptests.seed=deadbeef -Ptests.rerun=true--These properties can be set in your local gradle.properties. To force re-execution-of tests, even for the same master seed, apply cleanTest task:--gradlew -p lucene/core cleanTest test -Ptests.seed=deadbeef--The 'tests.iters' option should be sufficient for individual test cases-and is *much* faster than trying to duplicate re-runs of the entire-test suites. When it is absolutely needed to re-run an entire suite (because-of randomization in the static initialization, for example), you can do it-by running the 'beast' task with 'tests.dups' option:--gradlew -p lucene/core beast -Ptests.dups=10 --tests TestPerFieldDocValuesFormat--Note the filter (--tests) used to narrow down test reiterations to a particular-class. You can use any filter, including no filter at all, but it rarely makes-sense (will take ages). By default the test tasks generated by the 'beast' mode-use a random starting seed for randomization. If you pass an explicit seed, this-won't be the case (all tasks will use exactly the same starting seed):--gradlew -p lucene/core beast -Ptests.dups=10 --tests TestPerFieldDocValuesFormat -Dtests.seed=deadbeef---Verbose mode and debugging-----------------------------The "tests.verbose" mode switch enables standard streams from tests-to be dumped directly to the console. Run your verbose tests explicitly-specifying the project and test task or a fully qualified task path. Example:--gradlew -p lucene/core test -Ptests.verbose=true --tests "TestDemo"---Larger heap size-----------------------------By default tests run with a 512 MB max heap. But some tests (monster/nightly)-need more heap. Use "-Ptests.heapsize" for this:-- gradlew -p lucene/core test --tests "Test2BFST" -Ptests.heapsize=32g---Run GUI tests headlessly with Xvfb (Linux only)--------------------------------------------------GUI test for Luke application launches a window, this might mess up your-monitor depending on the display manager you are using. In that case,-you can install Xvfb (X Virtual Frame Buffer) so that the test runs on the-virtual display and does not open a real window.--# redhat-type OS-$ sudo yum install Xvfb--# ubuntu/debian-type OS-$ sudo apt install xvfb--# arch-$ sudo pacman -S xorg-server-xvfb---Profiling slow tests-----------------------The "tests.profile" mode switch turns on a sampling profiler during test execution,-and prints a simple summary at the end.--For example, top-10 histogram of methods (cpu samples):--gradlew -p lucene/core test -Ptests.profile=true--Alternatively, you can profile heap allocations instead:--gradlew -p lucene/core test -Ptests.profile=true -Ptests.profile.mode=heap--By default, results are computed (deduplicated) on just the method name, folding-together all events from the same method. To drill down further, you can increase the-stack size from the default of 1, to get a histogram of stacktraces instead:--gradlew -p lucene/core test -Ptests.profile=true -Ptests.profile.stacksize=8--For big methods, it can also be helpful to include line numbers for more granularity:--gradlew -p lucene/core test -Ptests.profile=true -Ptests.profile.linenumbers=true--Using these additional options will make the results more sparse, so it may be useful-to increase the top-N count:--gradlew -p lucene/core test -Ptests.profile=true -Ptests.profile.count=100---Generating Coverage Reports---------------------------------Running the "coverage" task (or setting the property "tests.coverage" to true)-will run the tests with instrumentation to record code coverage.--Example:--gradlew -p lucene/core coverage-open lucene/core/build/reports/jacoco/test/html/index.html--If you want to use test filtering to just check a particular test, specify-the "test" task explicitly before "coverage":--gradlew -p lucene/core test --tests TestDemo coverage-open lucene/core/build/reports/jacoco/test/html/index.html---External data sets---------------------Some tests may require external (and large) data sets. To see relevant tasks-that download and extract these data files automatically, run the following:--gradlew tasks --group "Data set download"diff --git a/help/workflow.txt b/help/workflow.mdsimilarity index 63%rename from help/workflow.txtrename to help/workflow.mdindex f69966d5abc..c6e8f57fa81 100644--- a/help/workflow.txt+++ b/help/workflow.md@@ -1,42 +1,73 @@-Typical workflow and tasks-==========================+# Typical workflow and tasksThis shows some typical workflow gradle commands.-Ensure your changes are correctly formatted (run "gradlew :helpFormatting" for more):+Ensure your changes are correctly formatted (run `gradlew :helpFormatting` for more):++```bashgradlew tidy+```Run tests on a module:++```bashgradlew -p lucene/core test+```++Run test of a single-class (run `gradlew :helpTests` for more):-Run test of a single-class (run "gradlew :helpTests" for more):+```bashgradlew -p lucene/core test --tests "*Demo*"+```Run all tests and validation checks on a module:++```bashgradlew -p lucene/core check+```Run all tests and validation checks on everything:++```bashgradlew check+```Run all validation checks but skip all tests:++```bashgradlew check -x test+```Assemble a single module's JAR (here for lucene-core):++```bashgradlew -p lucene/core assemblels lucene/core/build/libs+```Assemble all Lucene artifacts (JARs, and so on):++```bashgradlew assemble+```++Create all distributable packages, POMs, etc. and create a local maven repository for inspection:-Create all distributable packages, POMs, etc. and create a-local maven repository for inspection:+```bashgradlew mavenLocalls -R build/maven-local/+```-Assemble Javdocs on a module:+Assemble Javadocs on a module:++```bashgradlew -p lucene/core javadocls lucene/core/build/docs+```Assemble entire documentation (including javadocs):++```bashgradlew documentationls lucene/documentation/build/site+```diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/snowball/package-info.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/snowball/package-info.javaindex d0f2f70cff0..b80aa3693a7 100644--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/snowball/package-info.java+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/snowball/package-info.java@@ -24,7 +24,7 @@* <p>Lucene snowball classes require a few patches to the original Snowball source tree to generate* more efficient code.*- * <p>Refer to {@code gradle/generation/snowball*} and {@code help/regeneration.txt} files in Lucene+ * <p>Refer to {@code gradle/generation/snowball*} and {@code help/regeneration.md} files in Lucene* source code for instructions on how code regeneration from Snowball sources works, what* modifications are applied and what is required to regenerate snowball analyzers from scratch.*diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCaseParent.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCaseParent.javaindex 0f1035df27c..de91abea872 100644--- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCaseParent.java+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCaseParent.java@@ -213,7 +213,7 @@ public abstract sealed class LuceneTestCaseParent extends Assertpublic static final String DEFAULT_LINE_DOCS_FILE = "europarl.lines.txt.gz";/**- * Random sample from enwiki used in tests. See {@code help/tests.txt}. gradle task downloading+ * Random sample from enwiki used in tests. See {@code help/tests.md}. gradle task downloading* this data set: {@code gradlew getEnWikiRandomLines}.*/public static final String JENKINS_LARGE_LINE_DOCS_FILE = "enwiki.random.lines.txt";