Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/Core/AndroidNative/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {
url = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-maven/maven/v1'
name = 'dotnet-public-maven'
if (System.getenv('TF_BUILD') == 'True') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Moderate — 2/3 consensus | Case-sensitive string comparison is brittle

System.getenv('TF_BUILD') == 'True' is case-sensitive in Groovy. While Azure Pipelines documents the value as exactly True, any deviation (e.g., a wrapper script exporting TF_BUILD=true or TRUE) will silently fall through to google()/mavenCentral(). In a CFSClean environment, this causes an opaque 401 failure with no diagnostic.

Recommendation: Normalize once and compare case-insensitively:

def isCi = (System.getenv('TF_BUILD') ?: '').equalsIgnoreCase('true')

Optionally add a logger.lifecycle("Gradle repo routing: CI=\$\{isCi}") to make the routing decision visible in build logs.

maven {
url = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-maven/maven/v1'
name = 'dotnet-public-maven'
}

Copilot AI Apr 29, 2026

Copy link

Choose a reason for hiding this comment

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

As above, System.getenv('TF_BUILD') == 'True' is brittle. Prefer a presence check or case-insensitive boolean parse so CI reliably selects the Azure Artifacts feed.

Copilot uses AI. Check for mistakes.
} else {
google()
mavenCentral()
}

Copilot AI Apr 29, 2026

Copy link

Choose a reason for hiding this comment

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

Same as in settings.gradle: gating the Azure Artifacts repository solely on TF_BUILD == 'True' makes eng/ingest-maven-deps.sh ineffective when run locally (it will resolve from google()/mavenCentral() instead of the feed, so it won’t ingest). Add an explicit local override env var (used by the ingest script) so developers can intentionally run against dotnet-public-maven without pretending to be in CI.

Copilot uses AI. Check for mistakes.
}
dependencies {
Expand Down
47 changes: 22 additions & 25 deletions src/Core/AndroidNative/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
// Project Maven dependencies are resolved through the dnceng Azure Artifacts
// feed (dotnet-public-maven) for CFSClean network isolation compliance. The feed
// proxies Maven Central, Google Maven, and Gradle Plugin Portal. The credential
// provider plugin is fetched from a separate Azure Artifacts feed (artifacts-public).
//
// IMPORTANT: New packages must be ingested into the feed before CI can use them.
// The CI credential provider plugin skips auth in Azure Pipelines, so packages
// that aren't already in the feed will fail with 401. After adding or updating
// dependencies, run:
//
// ./eng/ingest-maven-deps.sh
// In CI (CFSClean network isolation), Maven dependencies resolve through the
// dnceng Azure Artifacts feed (dotnet-public-maven). Locally, standard Maven
// Central and Google Maven are used for faster builds.
//
// When adding or updating dependencies, run eng/ingest-maven-deps.sh to

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Critical — 3/3 consensus | eng/ingest-maven-deps.sh is broken by this change

The ingestion script runs ./gradlew build --refresh-dependencies locally (without TF_BUILD=True). After this PR, Gradle resolves from google()/mavenCentral() instead of the Azure Artifacts feed, so the core ingestion mechanism (pulling through the feed to trigger upstream caching) no longer works.

Additionally, the -Dazure.artifacts.credprovider.* system properties passed by the script are now dead code since the credential provider plugin was removed.

Impact: The next time a dependency is added, running eng/ingest-maven-deps.sh will appear to succeed (Gradle builds fine from Maven Central) but won't populate the Azure Artifacts feed. CI will then fail with 401 errors.

Recommendation: Update eng/ingest-maven-deps.sh to export TF_BUILD=True before invoking Gradle, so the script forces resolution through the Azure Artifacts feed regardless of environment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Minor (2/3 consensus)

The old comment included IMPORTANT: New packages must be ingested into the feed before CI can use them — with the credential provider plugin now removed, CI has no authenticated fallback for un-ingested packages (anonymous 401 with no helpful error). The "IMPORTANT" language was arguably more warranted now.

Suggestion: Consider restoring a stronger warning, e.g.:

// IMPORTANT: New packages must be ingested before CI can use them.
// Run ./eng/ingest-maven-deps.sh after adding or updating any Maven dependency.

// pre-populate the Azure Artifacts feed for CI.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Moderate — Missing 401 failure mode documentation [3/3 consensus]

The old comment block documented the specific CI failure mode: uningested packages fail with 401, and ingest-maven-deps.sh must be run to fix it. The new comment mentions the script but not why it's needed — the feed doesn't proxy on-demand, so new packages silently fail in CI until ingested.

Recommendation: Add a line explaining the failure mode, e.g.:

// If CI fails with "Could not GET ... 401", the package is not yet in the feed.
// Run eng/ingest-maven-deps.sh to pre-populate it.

// See: https://aka.ms/1es/netiso/CFS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Minor — Cross-reference to eng/init.gradle [2/3 consensus]

eng/init.gradle (injected by the CI pipeline template) handles project-level repository substitution via allprojects { repositories { ... } }, while this file handles settings-phase repos (pluginManagement, dependencyResolutionManagement). A brief cross-reference would help future maintainers understand the full CI repo-routing picture and avoid accidentally removing one half thinking it's redundant.


pluginManagement {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Minor (2/3 consensus after follow-up) — pluginManagement is secondary to buildscript resolution

Currently, AGP resolution works because build.gradle's buildscript { dependencies { classpath "com.android.tools.build:gradle:..." } } puts AGP on the classpath directly. The pluginManagement.repositories block is not load-bearing for plugin resolution today.

If a future refactor removes the buildscript block (migrating fully to plugins {} DSL), this pluginManagement section becomes the sole CI mechanism for resolving AGP — and would depend on dotnet-public-maven proxying Google Maven correctly.

Suggestion: A brief comment noting this relationship would help future maintainers avoid accidentally breaking CI when modernizing the Gradle setup, e.g.:

// NOTE: pluginManagement repos are currently secondary — AGP resolves via
// buildscript.dependencies in build.gradle. If buildscript is removed,
// this block becomes load-bearing for CI plugin resolution.

repositories {
maven {
url = 'https://pkgs.dev.azure.com/artifacts-public/PublicTools/_packaging/AzureArtifacts/maven/v1'
name = 'AzureArtifacts'
}
maven {
url = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-maven/maven/v1'
name = 'dotnet-public-maven'
if (System.getenv('TF_BUILD') == 'True') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Minor — 2/3 consensus | Duplicated conditional logic increases drift risk

The if (System.getenv('TF_BUILD') == 'True') pattern is repeated in 3 places across 2 files. Each serves a different Gradle scope (pluginManagement, buildscript, dependencyResolutionManagement) but they look identical with no indication of their distinct roles or backup mechanisms.

Recommendation: Extract to a variable at the top of each file:

def isCi = (System.getenv('TF_BUILD') ?: '').equalsIgnoreCase('true')

Then reuse isCi in all repository blocks. This also addresses the case-sensitivity concern above.

maven {
url = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-maven/maven/v1'
name = 'dotnet-public-maven'

Copilot AI Apr 29, 2026

Copy link

Choose a reason for hiding this comment

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

System.getenv('TF_BUILD') == 'True' is a very strict check; other CI environments or future Azure Pipelines changes may set TF_BUILD to a different truthy value (e.g., true, 1). Using a presence check (!= null) or a case-insensitive boolean parse would make the CI/local repo selection more robust.

Copilot uses AI. Check for mistakes.
}
} else {
google()
mavenCentral()
gradlePluginPortal()

Copilot AI Apr 29, 2026

Copy link

Choose a reason for hiding this comment

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

The Azure Artifacts feed is now only enabled when TF_BUILD == 'True', but eng/ingest-maven-deps.sh runs locally and relies on these Gradle files to resolve through dotnet-public-maven to ingest missing packages. With this condition, the ingest script will instead use google()/mavenCentral() unless the developer manually sets TF_BUILD, so it won’t pre-populate the feed as intended. Consider adding a separate opt-in env var (e.g., DOTNET_PUBLIC_MAVEN_INGEST=true) that also enables the feed locally, and update the ingest script/docs to set it when running ingestion.

Copilot uses AI. Check for mistakes.
}
}
}

plugins {
id 'com.microsoft.azure.artifacts.credprovider' version '1.1.1'
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
repositories {
maven {
url = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-maven/maven/v1'
name = 'dotnet-public-maven'
if (System.getenv('TF_BUILD') == 'True') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Moderate — 2/3 consensus | Non-obvious interaction with eng/init.gradle

In CI, init.gradle injects dotnet-public-maven as a project-level repo via allprojects { repositories { ... } }. Combined with PREFER_PROJECT mode, the init.gradle injection takes precedence — meaning this TF_BUILD conditional in dependencyResolutionManagement is actually a fallback, not the primary mechanism for project dependency resolution in CI.

Meanwhile, for pluginManagement.repositories and buildscript.repositories (lines 11 and build.gradle:4), init.gradle cannot reach those pre-project-evaluation contexts, so the TF_BUILD conditional there IS the sole CI guard.

This asymmetry is invisible to future maintainers.

Recommendation: Add a clarifying comment:

// NOTE: In CI, project-level repos injected by eng/init.gradle (via allprojects)
// take precedence (PREFER_PROJECT mode). This block is a safety net.
// For buildscript and pluginManagement, TF_BUILD is the sole CI guard.

maven {
url = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-maven/maven/v1'
name = 'dotnet-public-maven'
}
} else {
google()
mavenCentral()
}
}
}
Expand Down
Loading