Skip to content

[Build] Prevent Maven local from affecting default sbt builds - #1996

Merged
yili-db merged 5 commits into
unitycatalog:mainfrom
SomSamantray:fix-1874-remove-maven-local-resolver
Oct 24, 2026
Merged

yili-db merged 5 commits into
unitycatalog:mainfrom
SomSamantray:fix-1874-remove-maven-local-resolver

Conversation

@SomSamantray

@SomSamantray SomSamantray commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Description of changes

Default builds launched with the bundled build/sbt no longer resolve dependencies from ~/.m2/repository. The bundled launcher passes -Dsbt.override.build.repos=true, so its resolver chain comes from build/sbt-config/repositories; this prevents stale or POM-only local artifacts from breaking normal builds.

The Resolver.mavenLocal removal from build.sbt only affects a system sbt or IDE import. It does not control resolver selection for the bundled launcher.

Local Maven resolution remains available when needed: set USE_MAVEN_LOCAL=true to append Maven local after the configured repositories. It uses ~/.m2/repository. For example:

USE_MAVEN_LOCAL=true build/sbt "spark/compile"

CI enables this flag for source-built Spark rows and for every master-SNAPSHOT Delta row. The Delta source build has its own launcher, so project/scripts/build_delta.sh sets Delta's USE_MAVEN_LOCAL_FOR_SOURCE_SPARK=true while Delta publishes against UC's Maven artifacts and, when applicable, source-built Spark artifacts.

The resolver regression test lives in project/tests/test_sbt_resolvers.py because it checks the effective resolver chain produced by UC's bundled launcher. cross-spark-build.yml runs it separately from test_cross_spark_publish.py; the old substring grep was removed. The test disables sbt colors, strips ANSI escape codes before matching, and prints the command and captured output if sbt fails or the expected task output is missing.

Closes #1874.

  • Description of the changes is included above.
  • Added a regression test for default and opted-in resolver behavior.
  • Documentation update is not needed for this build-only fix.

Validation:

  • python3 project/tests/test_sbt_resolvers.py passed with JDK 17 for default and opted-in resolver behavior.

  • CI=true python3 project/tests/test_sbt_resolvers.py passed with JDK 17.

  • build/sbt -batch -J-Xmx1G "hadoop/compile" "spark/compile" passed.

  • bash -n build/sbt project/scripts/build_delta.sh, Python syntax compilation, and git diff --check passed.

  • The informational Spark 4.3.0-SNAPSHOT / Delta master-SNAPSHOT job's Delta initializer failure is also present on main and is unrelated to this change; it was left unchanged.

  • GitHub Actions runs for this pushed head are currently action_required pending maintainer approval; the DCO check passed.

AI disclosure: Codex assisted with investigation, implementation, testing, and review. The final diff was reviewed against the repository guidance.

@yili-db

yili-db commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] The direction is right: a stale or POM-only ~/.m2 shouldn't break default builds. But as written, this also cuts off UC's own source-build CI path (see inline).

nit: Under build/sbt the change that matters is the repositories file. -Dsbt.override.build.repos=true already makes the launcher ignore the build.sbt resolver, so that removal only affects a system sbt or an IDE import. Worth saying in the description.

@@ -1,6 +1,5 @@
[repositories]
local
maven-local: file://${user.home}/.m2/repository

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] UC's own build/sbt still needs ~/.m2 after this. Source-built Spark only lands there (build_spark.sh), and build_delta.sh only does publishM2, so integrationTests/test:compile / spark/jacoco with -DdeltaVersion=<SNAPSHOT> can't resolve. Can we mirror Delta's opt-in block from its build/sbt into ours and export the flag from prepare-spark-env and for the master-SNAPSHOT rows? Those rows are non-blocking, so please link a passing run of one source-Spark row and one Delta-SNAPSHOT row.

Also, the Delta-SNAPSHOT rows with released Spark need the opt-in too, so a name scoped to source-built Spark (USE_MAVEN_LOCAL_FOR_SOURCE_SPARK) would be misleading there. Maybe a more general name?

found_jars.add(jar_file.name)
return found_jars

def test_default_resolvers_exclude_maven_local(self) -> bool:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] What is this actually testing? It's a substring grep. It passes while the source-build path is broken, ignores build/sbt, and a comment containing maven-local: would fail it. Can we assert the resolvers sbt really uses (build/sbt "export fullResolvers"), once without the flag (no .m2) and once with it? Also, is the cross-Spark publish test the right place for this?

Comment thread project/scripts/build_delta.sh Outdated
Comment on lines +76 to +77
# filters them via pomPostProcess. USE_MAVEN_LOCAL_FOR_SOURCE_SPARK enables the
# local Maven resolver when a source-built Spark needs those artifacts.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] This variable is read by Delta's build/sbt, not ours, since we've already cd'd into $DELTA_DIR. Can the comment say so? It's also only set for source-built Spark, so the "UC jars are already in ~/.m2" line above is no longer how Delta finds UC jars with released Spark.

@yili-db

yili-db commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Thanks, the opt-in and the effective-resolver test address my earlier comments. Two things left, inline.

Comment thread project/tests/test_sbt_resolvers.py Outdated
env["USE_MAVEN_LOCAL"] = "true"

result = subprocess.run(
[str(UC_ROOT / "build/sbt"), "-batch", "show fullResolvers"],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] This fails in CI ("Build Test": sbt did not print any fullResolvers task results). With CI=true sbt colors its output, so the fullmatch never hits. Passing -no-colors fixes it (checked locally with CI=true). Can we also print sbt's stdout/stderr when this fails? The CI log had nothing to go on.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added -no-colors, strip ANSI escapes before matching, and include the command plus sbt stdout/stderr in failure messages. The resolver test passed locally with and without CI=true in commit 7ce1ad30845077debafee0c5a2be5c90825d9f57.

Comment thread build/sbt Outdated
cp "$SBT_REPOSITORIES_CONFIG" "$UC_SBT_TEMP_REPOSITORIES_CONFIG"
SBT_REPOSITORIES_CONFIG="$UC_SBT_TEMP_REPOSITORIES_CONFIG"
fi
MAVEN_LOCAL_REPO="${MAVEN_LOCAL_REPO:-${HOME}/.m2/repository}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Who sets MAVEN_LOCAL_REPO? Nothing in CI does, and the test pops it. Can we drop it until someone needs it? It's also unvalidated: a relative path gives file://tmp/m2, which sbt reads as a host.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed MAVEN_LOCAL_REPO support. USE_MAVEN_LOCAL=true now uses ~/.m2/repository directly, and the regression test confirms that behavior. This is in commit 7ce1ad30845077debafee0c5a2be5c90825d9f57.

@SomSamantray

Copy link
Copy Markdown
Contributor Author

I clarified that -Dsbt.override.build.repos=true makes the bundled launcher use the repositories file, while removing Resolver.mavenLocal from build.sbt affects system sbt and IDE imports. I also refreshed the validation section. Updated with commit 7ce1ad30845077debafee0c5a2be5c90825d9f57.

@yili-db

yili-db commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db
yili-db merged commit ad7f5a7 into unitycatalog:main Oct 24, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build.sbt: Resolver.mavenLocal makes the sbt build fragile to stale ~/.m2 cache state

2 participants