Skip to content

Fetch transitive POMs in gradle resolver #1411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

smocherla-brex
Copy link
Contributor

@smocherla-brex smocherla-brex commented Jul 10, 2025

Fixes #1409, also #909 is tangentially related (note that this PR doesn't solve all multiplatform cases, but it should fix a bug where we weren't downloading or pinning all transitive KMP artifacts for the JVM platform).

https://repo1.maven.org/maven2/com/squareup/okio/okio/3.15.0/ okio is a transitive dep of okhttp. It also turns out to be a Kotlin Multiplatform dependency with gradle metadata like

 {
      "name": "jvmRuntimeElements-published",
      "attributes": {
        "org.gradle.category": "library",
        "org.gradle.jvm.environment": "standard-jvm",
        "org.gradle.libraryelements": "jar",
        "org.gradle.usage": "java-runtime",
        "org.jetbrains.kotlin.platform.type": "jvm"
      },
      "available-at": {
        "url": "../../okio-jvm/3.15.0/okio-jvm-3.15.0.module",
        "group": "com.squareup.okio",
        "module": "okio-jvm",
        "version": "3.15.0"
      }
    },

basically pointing to the JVM artifact to be downloaded. The JAR for okio is basically a placeholder https://repo1.maven.org/maven2/com/squareup/okio/okio/3.15.0/okio-3.15.0.jar (it's not actually a valid jar) but right now we don't download it:

  • because gradle doesn't give us that as an artifact (because it's not in the gradle metadata)
  • we should get the POM file - but right now we fetch only the roots/POMs for artifacts specified by the user, and we request the POMs explicitly by their extension, but that won't fetch the transitive POMs. As a result, in the current logic we fail to fetch some transitive artifacts which are Kotlin Multiplatform/gradle metadata based dependencies as they are essentially children (okio-jvm, okio-js,...) of the base okio dependency .
  • To fix this, I've updated the logic to fetch the JARS for the base multiplatform coordinates like okio and fetch the POM for it, and indirectly its JAR. Even if this JAR is not useful in itself, it will ensure we get the children artifacts like okio-jvm and make them available in the final graph so that it can be used. This approach will help with other KMP dependencies as well.

I'm open to other approaches, but I updated the regression tests and the existing tests pass with this approach.


bazel query @regression_testing_gradle//:androidx_annotation_annotation_jvm >> "$TEST_LOG" 2>&1

# This is KMP artifact which is a transitive depndency

Choose a reason for hiding this comment

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

Typo: depndency

Copy link
Collaborator

@shs96c shs96c left a comment

Choose a reason for hiding this comment

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

LGTM. I think. Thank you for adding the extra tests!

@shs96c shs96c merged commit 1800f5f into bazel-contrib:master Jul 24, 2025
6 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.

When using gradle resolver, some dependencies are missing from the final lock_file (okhttp -> okio)
3 participants