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

davsclaus pushed a commit to branch ci-generated-only-no-dependents
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 81b14221c45d10a3b9272d3a4d5f372684eb6cb3
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Nov 28 10:06:37 2026 +0100

    chore: ci - a component change does not test camel-yaml-dsl and camel-jbang
    
    A component PR such as #30923 tested camel-yaml-dsl, camel-jbang-*, 
camel-launcher
    and the catalog modules, although they are in the EXCLUSION_LIST:
    
    - Scalpel's affected modules were merged into -pl including the ones 
Scalpel marks
      testsSkipped (the EXCLUSION_LIST). Being in -pl by name, filterExclusions 
then
      dropped their exclusions. Only the modules Scalpel would test are merged 
now.
    - Every component is a dependency of camel-allcomponents, so the -amd 
reactor (and
      Scalpel's downstream graph) of a component reaches camel-catalog and 
everything
      downstream of it. Maven's !: exclusion removes only the module itself, 
not its
      dependents, so camel-jbang-run, camel-jbang-plugin-tui, 
camel-jbang-plugin-mcp
      and camel-catalog-cve were tested on every component PR. 
camel-allcomponents is
      now a cut point: the modules reached only through it are excluded. Kept 
are the
      -amd reactor of a changed module downstream of it (camel-jbang-core still 
tests
      camel-jbang-plugin-tui) and of a module that uses a changed component 
directly
      (camel-chaos still tests camel-jbang-plugin-tui and camel-cli-connector).
    - A module where only src/generated changed (the catalog doc regenerated 
from the
      component doc) no longer expands to its dependents, and Scalpel ignores 
its
      generated files.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../actions/incremental-build/incremental-build.sh | 190 ++++++++++++++++++++-
 .../incremental_build_cut_test.sh                  | 175 +++++++++++++++++++
 2 files changed, 358 insertions(+), 7 deletions(-)

diff --git a/.github/actions/incremental-build/incremental-build.sh 
b/.github/actions/incremental-build/incremental-build.sh
index eac46b8eaa8a..54de033b7a77 100755
--- a/.github/actions/incremental-build/incremental-build.sh
+++ b/.github/actions/incremental-build/incremental-build.sh
@@ -50,6 +50,15 @@ maxNumberOfTestableProjects=50
 # Modules excluded from targeted testing (generated code, meta-modules, etc.)
 
EXCLUSION_LIST="!:camel-allcomponents,!:dummy-component,!:camel-catalog,!:camel-catalog-console,!:camel-catalog-maven,!:camel-catalog-suggest,!:camel-route-parser,!:camel-report-maven-plugin,!:camel-endpointdsl,!:camel-componentdsl,!:camel-endpointdsl-support,!:camel-yaml-dsl,!:camel-kamelet-main,!:camel-yaml-dsl-deserializers,!:camel-yaml-dsl-maven-plugin,!:camel-jbang-core,!:camel-jbang-main,!:camel-jbang-plugin-generate,!:camel-jbang-plugin-edit,!:camel-jbang-plugin-kubernetes,!:camel
 [...]
 
+# Sync-point modules that depend on every component (artifact IDs, 
comma-separated).
+# The modules downstream of a cut point (camel-catalog, camel-yaml-dsl, 
camel-jbang-*,
+# camel-launcher, ...) are not tested for a component change, as a component 
reaches
+# them only through the cut point. They are still tested when a module 
downstream of
+# the cut point changed itself (e.g. camel-jbang-core tests 
camel-jbang-plugin-tui).
+# Maven's !: exclusion is not enough for this: it removes the module itself 
from the
+# -amd reactor, not the modules downstream of it.
+CUT_POINT_MODULES="camel-allcomponents"
+
 
 # Allow projects to override the exclusion list
 # (e.g., camel-spring-boot has different modules than main Camel)
@@ -76,6 +85,36 @@ findProjectRoot() {
   echo "$path"
 }
 
+# Find the modules whose changed files are all generated (under the module's 
src/generated/).
+# A component change regenerates files in other modules: the catalog
+# (catalog/camel-catalog/src/generated/...), the endpoint DSL and the 
component DSL.
+# Such a module did not change on its own: the change is in the component, 
which is
+# tested. Testing the dependents of the regenerated module (-amd of 
camel-catalog is
+# camel-yaml-dsl, camel-jbang-*, camel-launcher, ...) tests code the PR did 
not touch.
+# Args: $1=changed file paths (newline-separated, relative to the repository 
root)
+# Prints the module root of each generated-only module, one per line.
+findGeneratedOnlyModules() {
+  local changed_files="$1"
+  local all_roots=","
+  local hand_written_roots=","
+  local file dir root
+  while read -r file; do
+    [ -z "$file" ] && continue
+    dir=$(dirname "$file")
+    root=$(findProjectRoot "$dir")
+    [[ "$root" = "." ]] && continue
+    all_roots="${all_roots}${root},"
+    if [[ "$file" != "${root}/src/generated/"* ]]; then
+      hand_written_roots="${hand_written_roots}${root},"
+    fi
+  done <<< "$changed_files"
+  for root in $(echo "$all_roots" | tr ',' '\n' | sort -u); do
+    if [[ "$hand_written_roots" != *",${root},"* ]]; then
+      echo "$root"
+    fi
+  done
+}
+
 # Remove exclusion entries that conflict with explicitly included modules.
 # When -amd pulls in dependents, the EXCLUSION_LIST prevents testing 
generated/meta
 # modules.  But when those modules are the *primary* changed modules, 
excluding them
@@ -108,6 +147,102 @@ filterExclusions() {
   echo "$result"
 }
 
+# Print the artifact IDs of $1 that are not in $2 (both newline-separated), 
sorted.
+subtractModules() {
+  local from="$1"
+  local remove="$2"
+  if [ -z "$remove" ]; then
+    echo "$from" | grep . | sort -u || true
+    return
+  fi
+  comm -23 <(echo "$from" | grep . | sort -u) <(echo "$remove" | grep . | sort 
-u) || true
+}
+
+# Modules to cut from the -amd reactor: the modules downstream of a cut point, 
minus
+# the modules downstream of a changed module that is itself downstream of the 
cut point,
+# minus the changed modules.
+# Args: $1=-amd reactor of the cut points, $2=-amd reactor of the changed 
modules that
+#   are downstream of the cut points, $3=artifact IDs of the changed modules
+#   (all newline-separated)
+computeCutModules() {
+  local cut_reactor="$1"
+  local keep_reactor="$2"
+  local changed_ids="$3"
+  subtractModules "$cut_reactor" "$(printf '%s\n%s\n' "$keep_reactor" 
"$changed_ids")"
+}
+
+# Print the artifact ID of the module of a pom.xml (the first one outside 
<parent>).
+moduleArtifactId() {
+  sed -n '/<parent>/,/<\/parent>/!{ 
s/.*<artifactId>\([^<]*\)<\/artifactId>.*/\1/p; }' "$1" | head -1
+}
+
+# Print the artifact IDs of the -amd reactor of a -pl list (newline-separated).
+amdReactorIds() {
+  ./mvnw -B -q -amd exec:exec -Dexec.executable="echo" \
+    -Dexec.args='${project.artifactId}' -pl "$1" 2>/dev/null | grep -v '^\[' 
|| true
+}
+
+# Find the modules to cut from the -amd reactor of the changed modules (see 
CUT_POINT_MODULES).
+# Kept are the changed modules, and the -amd reactor of the changed modules 
located
+# downstream of a cut point and of the modules downstream of a cut point that 
declare a
+# dependency on a changed module (e.g. camel-jbang-plugin-tui uses 
camel-chaos).
+# Args: $1=changed modules (comma-separated paths or :artifactIds), $2=-amd 
reactor of them
+# Prints the artifact IDs to cut, one per line.
+findCutModules() {
+  local changed_pl="$1"
+  local reactor="$2"
+
+  local changed_ids="" path
+  for path in $(echo "$changed_pl" | tr ',' '\n'); do
+    if [[ "$path" == :* ]]; then
+      changed_ids="${changed_ids}${path#:}"$'\n'
+    elif [ -f "$path/pom.xml" ]; then
+      changed_ids="${changed_ids}$(moduleArtifactId "$path/pom.xml")"$'\n'
+    fi
+  done
+
+  local cut_points="" cp
+  for cp in $(echo "$CUT_POINT_MODULES" | tr ',' '\n'); do
+    if echo "$reactor" | grep -qxF "$cp" && ! echo "$changed_ids" | grep -qxF 
"$cp"; then
+      cut_points="${cut_points:+${cut_points},}:${cp}"
+    fi
+  done
+  if [ -z "$cut_points" ]; then
+    return 0
+  fi
+
+  local cut_reactor
+  cut_reactor=$(amdReactorIds "$cut_points")
+  if [ -z "$cut_reactor" ]; then
+    return 0
+  fi
+
+  # Changed modules downstream of a cut point, and modules downstream of a cut 
point
+  # that depend on a changed module directly: their -amd reactor stays.
+  local keep_roots="" id pom dep_id
+  for id in $changed_ids; do
+    if echo "$cut_reactor" | grep -qxF "$id"; then
+      keep_roots="${keep_roots}${id}"$'\n'
+    fi
+    for pom in $(git grep -l -F "<artifactId>${id}</artifactId>" -- '*pom.xml' 
':!*/src/*' 2>/dev/null); do
+      dep_id=$(moduleArtifactId "$pom")
+      # A cut point depends on every component: it is not a direct user
+      if [[ ",${CUT_POINT_MODULES}," == *",${dep_id},"* ]]; then
+        continue
+      fi
+      if [ "$dep_id" != "$id" ] && echo "$cut_reactor" | grep -qxF "$dep_id"; 
then
+        keep_roots="${keep_roots}${dep_id}"$'\n'
+      fi
+    done
+  done
+  local keep_reactor=""
+  if [ -n "$(echo "$keep_roots" | grep .)" ]; then
+    keep_reactor=$(amdReactorIds "$(echo "$keep_roots" | grep . | sort -u | 
sed 's/^/:/' | paste -sd, -)")
+  fi
+
+  computeCutModules "$cut_reactor" "$keep_reactor" "$changed_ids"
+}
+
 # Count the modules a build would test: the -amd reactor of the changed modules
 # plus the dependency-detected modules (grep + Scalpel), without duplicates.
 # The dependency-detected modules are added to -pl next to the -amd reactor, 
so the
@@ -246,7 +381,9 @@ analyzePomDependencies() {
 # Run Scalpel in report mode to detect modules affected by POM changes.
 # Sets caller-visible variables: scalpel_module_ids, scalpel_module_paths,
 #   scalpel_props, scalpel_managed_deps, scalpel_managed_plugins
+# Args: $1=module roots where only generated files changed (newline-separated, 
may be empty)
 runScalpelDetection() {
+  local generated_only_modules="${1:-}"
   echo "  Running Scalpel change detection..."
 
   # Scalpel is permanently configured in .mvn/extensions.xml.
@@ -264,6 +401,8 @@ runScalpelDetection() {
   #   mvnw, mvnw.cmd and pom.xml are left out on purpose: they do affect the 
build.
   #   A pattern without a "/" also matches at any depth (e.g. a module's 
README.md);
   #   the file-path step above still picks up the module of such a file.
+  #   The src/generated/** of a generated-only module is excluded as well, so 
Scalpel
+  #   does not report the dependents of a regenerated catalog or endpoint DSL.
   # - skipTestsForDownstreamModules: derived from EXCLUSION_LIST — tells 
Scalpel which
   #   downstream modules should not run tests in skip-tests mode (for shadow 
comparison)
   # Strip the Maven "!:" prefix from each entry to get bare artifact IDs for 
Scalpel.
@@ -273,6 +412,10 @@ runScalpelDetection() {
   # auto-detection is fragile across Maven wrappers and CI rerun contexts.
   local base_branch="origin/${GITHUB_BASE_REF:-main}"
   local 
exclude_paths=".github/**,AGENTS.md,CLAUDE.md,CONTRIBUTING.md,README.md,SECURITY.md,KEYS,LICENSE.txt,NOTICE.txt,doap.rdf,Jenkinsfile*,.asf.yaml,.gitattributes,.gitignore,.gitmodules,.sdkmanrc,jbang-catalog.json"
+  local gen_root
+  for gen_root in $generated_only_modules; do
+    exclude_paths="${exclude_paths},${gen_root}/src/generated/**"
+  done
   local scalpel_args="-Dscalpel.enabled=true -Dscalpel.mode=report 
-Dscalpel.explain=true -Dscalpel.fullBuildTriggers= 
-Dscalpel.fetchBaseBranch=false -Dscalpel.baseBranch=${base_branch} 
-Dscalpel.excludePaths=${exclude_paths} 
-Dscalpel.skipTestsForDownstreamModules=${skip_downstream}"
 
   # Verify merge base is reachable (pre-fetched by the CI workflow step)
@@ -321,8 +464,11 @@ runScalpelDetection() {
     report="$filtered_report"
   fi
 
-  # Extract affected module artifactIds (colon-prefixed for Maven -pl 
compatibility)
-  scalpel_module_ids=$(jq -r '.affectedModules[].artifactId' "$report" 
2>/dev/null | sort -u | sed 's/^/:/' | tr '\n' ',' | sed 's/,$//' || true)
+  # Extract the artifactIds of the affected modules whose tests Scalpel would 
run
+  # (colon-prefixed for Maven -pl compatibility). The modules with 
testsSkipped are the
+  # EXCLUSION_LIST passed as skipTestsForDownstreamModules: putting them in 
-pl by name
+  # would make filterExclusions drop their exclusions, and their tests would 
run.
+  scalpel_module_ids=$(jq -r '.affectedModules[] | select(.testsSkipped != 
true) | .artifactId' "$report" 2>/dev/null | sort -u | sed 's/^/:/' | tr '\n' 
',' | sed 's/,$//' || true)
   scalpel_module_paths=$(jq -r '.affectedModules[].path' "$report" 2>/dev/null 
| sort -u | tr '\n' ',' | sed 's/,$//' || true)
   scalpel_props=$(jq -r '(.changedProperties // []) | if length > 0 then 
join(", ") else "" end' "$report" 2>/dev/null || true)
   scalpel_managed_deps=$(jq -r '(.changedManagedDependencies // []) | if 
length > 0 then join(", ") else "" end' "$report" 2>/dev/null || true)
@@ -790,6 +936,12 @@ main() {
   done
   pl="${pl:1}"  # strip leading comma
 
+  # Modules where only generated files changed (catalog, endpoint DSL, 
component DSL
+  # regenerated by a component change). They are built like pom-only modules 
(without
+  # -amd), and Scalpel ignores their generated files, so their dependents are 
not tested.
+  local generated_only_modules
+  generated_only_modules=$(findGeneratedOnlyModules "$(echo "$diff_body" | sed 
-n -e '/^diff --git a/p' | awk '{print $3}' | cut -b 3-)")
+
   # Only analyze parent/pom.xml for grep-based dependency detection
   # (matches original detect-test.sh behavior)
   if echo "$diff_body" | grep -q '^diff --git a/parent/pom.xml'; then
@@ -847,7 +999,7 @@ main() {
   # comparison with the grep-based approach.
   echo ""
   echo "Running Scalpel change detection..."
-  runScalpelDetection
+  runScalpelDetection "$generated_only_modules"
 
   # Save grep-only results for comment attribution (before merging with 
Scalpel).
   # The comment's top section shows only what the current grep mechanism 
detected;
@@ -874,11 +1026,15 @@ main() {
   # Pom-only modules (e.g. "parent", aggregator poms) are kept in the build
   # list but must NOT be expanded with -amd, since that would pull in every
   # dependent module. Modules with src/main (including test-infra modules)
-  # are treated as testable so their dependents get tested.
+  # are treated as testable so their dependents get tested, unless only their
+  # generated files changed (see findGeneratedOnlyModules).
   local testable_pl=""
   local pom_only_pl=""
   for w in $(echo "$pl" | tr ',' '\n'); do
-    if [ -d "$w/src/main" ]; then
+    if echo "$generated_only_modules" | grep -qxF "$w"; then
+      pom_only_pl="${pom_only_pl:+${pom_only_pl},}${w}"
+      echo "  Generated-only module (only src/generated changed, won't expand 
dependents): $w"
+    elif [ -d "$w/src/main" ]; then
       testable_pl="${testable_pl:+${testable_pl},}${w}"
     else
       pom_only_pl="${pom_only_pl:+${pom_only_pl},}${w}"
@@ -930,6 +1086,8 @@ main() {
   # Reactor artifact IDs resolved by the threshold check below.
   # Reused later to validate -pl exclusions against the -amd reactor.
   local reactor_ids=""
+  # Modules of the -amd reactor reached only through a cut point (see 
findCutModules)
+  local cut_ids=""
 
   if [ -n "$testable_pl" ]; then
     # File-path modules with tests — use -amd to catch dependents
@@ -952,7 +1110,18 @@ main() {
       local totalTestableProjects
       reactor_ids=$(./mvnw -B -q -amd exec:exec -Dexec.executable="echo" \
         -Dexec.args='${project.artifactId}' -pl "$threshold_pl" 2>/dev/null || 
true)
-      totalTestableProjects=$(countTestableModules "$reactor_ids" 
"$dep_module_ids")
+      # Cut the modules that the changed modules reach only through a cut point
+      # (camel-allcomponents): a component change does not test 
camel-yaml-dsl, camel-jbang-*, ...
+      cut_ids=$(findCutModules "$threshold_pl" "$reactor_ids")
+      if [ -n "$cut_ids" ]; then
+        echo "Not testing $(echo "$cut_ids" | grep -c .) modules reached only 
through ${CUT_POINT_MODULES}:"
+        echo "$cut_ids" | sed 's/^/  - /'
+        if [ -n "$dep_module_ids" ]; then
+          dep_module_ids=$(subtractModules "$(echo "$dep_module_ids" | tr ',' 
'\n' | sed 's/^://')" "$cut_ids" | sed 's/^/:/' | paste -sd, -)
+        fi
+        final_pl=$(echo "$final_pl" | tr ',' '\n' | grep -vxF -f <(echo 
"$cut_ids" | sed 's/^/:/') | paste -sd, - || true)
+      fi
+      totalTestableProjects=$(countTestableModules "$(subtractModules 
"$reactor_ids" "$cut_ids")" "$dep_module_ids")
 
       if [[ ${totalTestableProjects} -gt ${maxNumberOfTestableProjects} ]]; 
then
         echo "Too many dependent modules (${totalTestableProjects} > 
${maxNumberOfTestableProjects}), testing only the affected modules"
@@ -1036,6 +1205,13 @@ main() {
         filtered_exclusions="$valid_exclusions"
       fi
     fi
+    # Exclude the cut modules too (all of them are in the -amd reactor of the 
threshold check)
+    local cut_id
+    for cut_id in $cut_ids; do
+      if [[ ",${filtered_exclusions}," != *",!:${cut_id},"* ]] && echo 
"$reactor_ids" | grep -qxF "$cut_id"; then
+        
filtered_exclusions="${filtered_exclusions:+${filtered_exclusions},}!:${cut_id}"
+      fi
+    done
     local build_pl_with_exclusions="$build_pl"
     if [ -n "$filtered_exclusions" ]; then
       build_pl_with_exclusions="${build_pl},${filtered_exclusions}"
@@ -1080,7 +1256,7 @@ main() {
   local tested_reactor_ids=""
   if [ -n "$reactor_ids" ]; then
     local excl_set
-    excl_set=$(echo "$EXCLUSION_LIST" | sed 's/!://g' | tr ',' '\n')
+    excl_set=$(printf '%s\n%s\n' "$(echo "$EXCLUSION_LIST" | sed 's/!://g' | 
tr ',' '\n')" "$cut_ids")
     tested_reactor_ids=$(echo "$reactor_ids" | while read -r rid; do
       if ! echo "$excl_set" | grep -qx "$rid"; then
         echo "$rid"
diff --git a/.github/actions/incremental-build/incremental_build_cut_test.sh 
b/.github/actions/incremental-build/incremental_build_cut_test.sh
new file mode 100755
index 000000000000..a717e14a12fb
--- /dev/null
+++ b/.github/actions/incremental-build/incremental_build_cut_test.sh
@@ -0,0 +1,175 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+# Unit tests for the functions of incremental-build.sh that keep a component 
change
+# from testing the modules downstream of camel-allcomponents and of a 
regenerated
+# catalog: findGeneratedOnlyModules, moduleArtifactId, subtractModules and
+# computeCutModules.
+
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Extract and load only the functions under test from incremental-build.sh 
without
+# running main() (same approach as incremental_build_filter_test.sh).
+for fn in findProjectRoot findGeneratedOnlyModules moduleArtifactId 
subtractModules computeCutModules; do
+  _fn_body=$(awk -v name="$fn" '
+    $0 ~ "^" name "\\(\\)" { in_fn=1; depth=0 }
+    in_fn {
+      for (i=1; i<=length($0); i++) {
+        c = substr($0, i, 1)
+        if (c == "{") depth++
+        if (c == "}") depth--
+      }
+      print
+      if (in_fn && depth == 0) { in_fn=0 }
+    }
+  ' "${SCRIPT_DIR}/incremental-build.sh")
+  eval "$_fn_body"
+done
+
+pass=0
+fail=0
+
+assert_eq() {
+  local expected="$1"
+  local actual="$2"
+  local message="$3"
+  if [[ "$expected" == "$actual" ]]; then
+    pass=$((pass + 1))
+  else
+    echo "FAIL: $message"
+    echo "  expected: [$expected]"
+    echo "  actual:   [$actual]"
+    fail=$((fail + 1))
+  fi
+}
+
+# A small module tree to resolve module roots against
+work_dir=$(mktemp -d)
+trap 'rm -rf "$work_dir"' EXIT
+mkpom() {
+  mkdir -p "$work_dir/$1"
+  cat > "$work_dir/$1/pom.xml" <<EOF
+<project>
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>$2</artifactId>
+  </parent>
+  <artifactId>$3</artifactId>
+  <dependencies>
+    <dependency>
+      <artifactId>camel-support</artifactId>
+    </dependency>
+  </dependencies>
+</project>
+EOF
+}
+mkpom catalog/camel-catalog catalog camel-catalog
+mkpom components/camel-thrift components camel-thrift
+mkpom dsl/camel-endpointdsl dsl camel-endpointdsl
+mkpom docs camel-parent docs
+cd "$work_dir"
+
+catalog_doc="catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/thrift-component.adoc"
+catalog_json="catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/thrift.json"
+thrift_doc="components/camel-thrift/src/main/docs/thrift-component.adoc"
+thrift_java="components/camel-thrift/src/main/java/org/apache/camel/component/thrift/ThriftProducer.java"
+thrift_generated="components/camel-thrift/src/generated/java/org/apache/camel/component/thrift/ThriftEndpointConfigurer.java"
+endpointdsl_generated="dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ThriftEndpointBuilderFactory.java"
+
+# ── findGeneratedOnlyModules ──
+
+# 1. A component change regenerates the catalog doc: only the catalog is 
generated-only
+result=$(findGeneratedOnlyModules "$(printf '%s\n' "$catalog_doc" 
"$catalog_json" "$thrift_doc" "$thrift_java" "$thrift_generated")")
+assert_eq "catalog/camel-catalog" "$result" \
+  "catalog with only generated files is generated-only, the component is not"
+
+# 2. Endpoint DSL and catalog both regenerated
+result=$(findGeneratedOnlyModules "$(printf '%s\n' "$catalog_json" 
"$endpointdsl_generated" "$thrift_java")")
+assert_eq "$(printf '%s\n' catalog/camel-catalog dsl/camel-endpointdsl)" 
"$result" \
+  "catalog and endpoint DSL are both generated-only"
+
+# 3. A hand-written change in the catalog keeps it a normal module
+result=$(findGeneratedOnlyModules "$(printf '%s\n' "$catalog_doc" 
"catalog/camel-catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java")")
+assert_eq "" "$result" \
+  "catalog with a src/main change is not generated-only"
+
+# 4. A change to the pom of the catalog keeps it a normal module
+result=$(findGeneratedOnlyModules "$(printf '%s\n' "$catalog_json" 
"catalog/camel-catalog/pom.xml")")
+assert_eq "" "$result" \
+  "catalog with a pom.xml change is not generated-only"
+
+# 5. Files outside any module and docs pages are ignored or hand-written
+result=$(findGeneratedOnlyModules "$(printf '%s\n' 
".github/workflows/pr-build-main.yml" 
"docs/user-manual/modules/ROOT/pages/index.adoc" "CLAUDE.md")")
+assert_eq "" "$result" \
+  "root files and docs pages are not generated-only modules"
+
+# 6. Empty input
+result=$(findGeneratedOnlyModules "")
+assert_eq "" "$result" \
+  "no changed files: no generated-only modules"
+
+# ── moduleArtifactId ──
+
+# 7. The artifactId of the module, not the one of its parent
+assert_eq "camel-thrift" "$(moduleArtifactId components/camel-thrift/pom.xml)" 
\
+  "moduleArtifactId skips the parent and reads the module's own artifactId"
+
+# ── subtractModules ──
+
+# 8. Set difference, sorted
+result=$(subtractModules "$(printf '%s\n' c a b)" "$(printf '%s\n' b)")
+assert_eq "$(printf '%s\n' a c)" "$result" \
+  "subtractModules removes the second list from the first"
+
+# 9. Nothing to remove
+result=$(subtractModules "$(printf '%s\n' b a)" "")
+assert_eq "$(printf '%s\n' a b)" "$result" \
+  "subtractModules with an empty second list returns the first, sorted"
+
+# 10. Names are matched exactly, not by prefix
+result=$(subtractModules "$(printf '%s\n' camel-yaml-dsl 
camel-yaml-dsl-validator)" "camel-yaml-dsl")
+assert_eq "camel-yaml-dsl-validator" "$result" \
+  "subtractModules does not remove a module whose name only starts with a 
removed one"
+
+# ── computeCutModules ──
+
+cut_reactor=$(printf '%s\n' camel-allcomponents camel-catalog 
camel-catalog-cve camel-yaml-dsl \
+  camel-jbang-core camel-jbang-run camel-jbang-plugin-tui 
camel-jbang-plugin-mcp)
+
+# 11. A component with no direct user downstream of camel-allcomponents: all 
is cut
+result=$(computeCutModules "$cut_reactor" "" "camel-thrift")
+assert_eq "$(echo "$cut_reactor" | sort)" "$result" \
+  "component change: every module downstream of camel-allcomponents is cut"
+
+# 12. A component used by camel-jbang-plugin-tui (camel-chaos): the tui plugin 
stays
+result=$(computeCutModules "$cut_reactor" "camel-jbang-plugin-tui" 
"camel-chaos")
+assert_eq "$(echo "$cut_reactor" | grep -vx camel-jbang-plugin-tui | sort)" 
"$result" \
+  "direct user of the changed component is kept"
+
+# 13. A change to camel-jbang-core keeps its own dependents
+result=$(computeCutModules "$cut_reactor" "$(printf '%s\n' camel-jbang-core 
camel-jbang-run camel-jbang-plugin-tui camel-jbang-plugin-mcp)" "$(printf 
'%s\n' camel-thrift camel-jbang-core)")
+assert_eq "$(printf '%s\n' camel-allcomponents camel-catalog camel-catalog-cve 
camel-yaml-dsl)" "$result" \
+  "changed module downstream of the cut point keeps its -amd reactor"
+
+echo ""
+echo "incremental_build_cut_test.sh: ${pass} passed, ${fail} failed"
+if [[ "$fail" -ne 0 ]]; then
+  exit 1
+fi

Reply via email to