grab / grazel

A tool to migrate Android projects from Gradle to Bazel incrementally and automatically

Home Page:https://grab.github.io/grazel/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BUILD.bazel not generated.

sylwek845 opened this issue · comments

Problem 1.
Not sure why this is happening but it seems like some of my modules getting the Deleted test/test_fixtures_ui/BUILD.bazel and I don;t see the migrated BUILD.bazel file

> Task :test:test_fixtures_ui:generateBazelScripts
Deleted test/test_fixtures_ui/BUILD.bazel

> Task :test:test_fixtures:generateBazelScripts
Generated test/test_fixtures/BUILD.bazel

my config

grazel {
    android {
        features {
            dataBinding = true
        }
        variantFilter {
            this.setIgnore(name != "release" && name != "prodEnv")
        }
        ndkApiLevel = 28
    }

    rules {
        bazelCommon {
            gitRepository {
                commit = "646475fa68b984f476871f0e8073234e8cae559c" // Commit hash
                remote = "https://github.com/grab/grab-bazel-common.git"
            }
        }
        test {
            enableTestMigration = true
            detectSourceSets = true
        }
        dependencies {
            overrideArtifactVersions.add("androidx.navigation:navigation-runtime:2.3.2")
        }
        mavenInstall {
            httpArchiveRepository {
                sha256 = "b17d7388feb9bfa7f2fa09031b32707df529f26c91ab9e5d909eb1676badd9a6"
                stripPrefix = "rules_jvm_external-4.5"
                url = "https://github.com/bazelbuild/rules_jvm_external/archive/4.5.zip"
            }
            artifactPinning {
                enabled.set(false)
            }
            versionConflictPolicy = "pinned"
        }
    }

Problem 2.

When I enable artifactPinning I get dependency conflict ->

Error in fail: Error while fetching artifact with coursier: Resolution error: Conflicting dependencies:
androidx.navigation:navigation-runtime:2.3.2 or [2.3.0] or [2.4.0] wanted by

  androidx.hilt:hilt-navigation:1.0.0 wants 2.3.2
  └─ androidx.hilt:hilt-navigation-compose:1.0.0

  androidx.navigation:navigation-fragment:2.3.0 wants [2.3.0]
  └─ com.datadoghq:dd-sdk-android:1.15.0

  androidx.navigation:navigation-runtime-ktx:2.4.0 wants [2.4.0]
  ├─ androidx.navigation:navigation-compose:2.4.0 wants androidx.navigation:navigation-runtime-ktx:[2.4.0]
  │  └─ androidx.hilt:hilt-navigation-compose:1.0.0
  └─ com.datadoghq:dd-sdk-android:1.15.0 wants androidx.navigation:navigation-runtime-ktx:2.3.0

but adding overrideArtifactVersions.add("androidx.navigation:navigation-runtime:2.3.2") doesn't work at all.

and I do get the same

> Task :test:test_fixtures_ui:generateBazelScripts
Deleted test/test_fixtures_ui/BUILD.bazel

Hey @sylwek845 thanks for reporting this. Adding a bit of context for this behavior, this is due to the fact that Grazel tries to do incremental migration by default. We explain it here https://grab.github.io/Grazel/migration_criteria/#migration-criteria. The problem is that the check is not as exhaustive and we don't have good tooling yet to display statistics on what was migrated. For fixing this we need two this at least

  1. Add capability to disable incremental migration or provide custom lambda in grazel {} in addition to default MigrationCriteria.
  2. Ensure Grazel generates transitive closure of maven targets in WORKSPACE as well to let versionConflictPolicy = "pinned" to work. Gradle and rules_jvm_external does dependency resolution differently, the proper way to fix it is ensure Grazel generates pinned versions of all artifacts (including transitives) in the project. Then rules_jvm_external won't throw dependency resolution conflicts. This is currently being done as part of rewrite here #45. Will target this for 0.5.0.