From 76fd9511d934b01a69539faa5b531672ec2aa71d Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Wed, 1 Nov 2023 13:03:38 +0800 Subject: [PATCH 1/3] Refactor GradleProjectInfo to use data from workspace dependencies instead of Configuration API --- .../com/grab/grazel/di/GrazelComponent.kt | 3 +- .../grab/grazel/gradle/GradleProjectInfo.kt | 46 +++--- .../migrate/internal/RootBazelFileBuilder.kt | 15 +- .../migrate/internal/WorkspaceBuilder.kt | 12 +- .../internal/GenerateRootBazelScriptsTask.kt | 31 ++-- maven_install.json | 142 +++++++++--------- 6 files changed, 141 insertions(+), 108 deletions(-) diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/di/GrazelComponent.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/di/GrazelComponent.kt index 5171b7a7..434a2d54 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/di/GrazelComponent.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/di/GrazelComponent.kt @@ -75,7 +75,8 @@ internal interface GrazelComponent { fun migrationChecker(): Lazy fun projectBazelFileBuilderFactory(): Lazy fun workspaceBuilderFactory(): Lazy - fun rootBazelFileBuilder(): Lazy + fun rootBazelFileFactory(): Lazy + fun gradleProjectInfoFactory(): Lazy fun artifactPinner(): Lazy fun dependenciesDataSource(): Lazy fun mavenInstallArtifactsCalculator(): Lazy diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/gradle/GradleProjectInfo.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/gradle/GradleProjectInfo.kt index 82722654..c446a0a0 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/gradle/GradleProjectInfo.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/gradle/GradleProjectInfo.kt @@ -17,10 +17,9 @@ package com.grab.grazel.gradle import com.grab.grazel.GrazelExtension -import com.grab.grazel.bazel.rules.DAGGER_GROUP import com.grab.grazel.di.qualifiers.RootProject -import com.grab.grazel.gradle.dependencies.DependenciesDataSource import com.grab.grazel.gradle.dependencies.DependencyGraphs +import com.grab.grazel.gradle.dependencies.model.WorkspaceDependencies import dagger.Lazy import org.gradle.api.Project import javax.inject.Inject @@ -33,35 +32,44 @@ interface GradleProjectInfo { val rootProject: Project val grazelExtension: GrazelExtension val hasDagger: Boolean - val hasDatabinding: Boolean val hasAndroidExtension: Boolean val hasGooglePlayServices: Boolean } -@Singleton -@Suppress("UnstableApiUsage") -internal class DefaultGradleProjectInfo @Inject constructor( - @param:RootProject +internal class DefaultGradleProjectInfo( override val rootProject: Project, override val grazelExtension: GrazelExtension, private val dependencyGraphsProvider: Lazy, - internal val dependenciesDataSource: DependenciesDataSource + private val workspaceDependencies: WorkspaceDependencies ) : GradleProjectInfo { + @Singleton + class Factory + @Inject constructor( + @param:RootProject + private val rootProject: Project, + private val grazelExtension: GrazelExtension, + private val dependencyGraphsProvider: Lazy, + ) { + fun create( + workspaceDependencies: WorkspaceDependencies + ): GradleProjectInfo = DefaultGradleProjectInfo( + rootProject, + grazelExtension, + dependencyGraphsProvider, + workspaceDependencies + ) + } + private val projectGraph: DependencyGraphs get() = dependencyGraphsProvider.get() override val hasDagger: Boolean by lazy { - projectGraph.nodes().any { project -> - dependenciesDataSource - .mavenDependencies(project) - .any { dependency -> dependency.group == DAGGER_GROUP } - } - } - - override val hasDatabinding: Boolean by lazy { - projectGraph - .nodes() - .any { it.hasDatabinding } + workspaceDependencies + .result + .values + .parallelStream() + .flatMap { it.stream() } + .anyMatch { it.shortId.contains("com.google.dagger") } } override val hasAndroidExtension: Boolean by lazy { diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/internal/RootBazelFileBuilder.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/internal/RootBazelFileBuilder.kt index 6acf53ee..f680d241 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/internal/RootBazelFileBuilder.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/internal/RootBazelFileBuilder.kt @@ -27,12 +27,23 @@ import com.grab.grazel.bazel.starlark.statements import com.grab.grazel.gradle.GradleProjectInfo import com.grab.grazel.migrate.BazelFileBuilder import javax.inject.Inject +import javax.inject.Singleton -internal class RootBazelFileBuilder @Inject constructor( +internal class RootBazelFileBuilder( private val gradleProjectInfo: GradleProjectInfo, - private val grazelExtension: GrazelExtension + private val grazelExtension: GrazelExtension, ) : BazelFileBuilder { + @Singleton + class Factory + @Inject + constructor(private val grazelExtension: GrazelExtension) { + fun create(gradleProjectInfo: GradleProjectInfo) = RootBazelFileBuilder( + gradleProjectInfo, + grazelExtension + ) + } + override fun build(): List = statements { setupKotlin() if (gradleProjectInfo.hasDagger) daggerBuildRules() diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/internal/WorkspaceBuilder.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/internal/WorkspaceBuilder.kt index de44278a..c0621afc 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/internal/WorkspaceBuilder.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/internal/WorkspaceBuilder.kt @@ -39,6 +39,7 @@ import com.grab.grazel.bazel.starlark.StatementsBuilder import com.grab.grazel.bazel.starlark.add import com.grab.grazel.bazel.starlark.statements import com.grab.grazel.di.qualifiers.RootProject +import com.grab.grazel.gradle.DefaultGradleProjectInfo import com.grab.grazel.gradle.GradleProjectInfo import com.grab.grazel.gradle.dependencies.model.WorkspaceDependencies import com.grab.grazel.gradle.isAndroidApplication @@ -59,20 +60,23 @@ internal class WorkspaceBuilder( private val mavenInstallArtifactsCalculator: MavenInstallArtifactsCalculator ) : BazelFileBuilder { @Singleton - class Factory @Inject constructor( + class Factory + @Inject + constructor( @param:RootProject private val rootProject: Project, private val grazelExtension: GrazelExtension, - private val gradleProjectInfo: GradleProjectInfo, - private val mavenInstallArtifactsCalculator: MavenInstallArtifactsCalculator + private val gradleProjectInfoFactory: DefaultGradleProjectInfo.Factory, + private val mavenInstallArtifactsCalculator: MavenInstallArtifactsCalculator, ) { fun create( projectsToMigrate: List, + gradleProjectInfo: GradleProjectInfo, workspaceDependencies: WorkspaceDependencies = WorkspaceDependencies(emptyMap()), ) = WorkspaceBuilder( rootProject, projectsToMigrate, grazelExtension, - gradleProjectInfo, + gradleProjectInfoFactory.create(workspaceDependencies), workspaceDependencies, mavenInstallArtifactsCalculator ) diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/tasks/internal/GenerateRootBazelScriptsTask.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/tasks/internal/GenerateRootBazelScriptsTask.kt index 7139fc41..e921acdf 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/tasks/internal/GenerateRootBazelScriptsTask.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/tasks/internal/GenerateRootBazelScriptsTask.kt @@ -19,6 +19,8 @@ package com.grab.grazel.tasks.internal import com.grab.grazel.bazel.starlark.writeToFile import com.grab.grazel.di.GrazelComponent import com.grab.grazel.di.qualifiers.RootProject +import com.grab.grazel.gradle.DefaultGradleProjectInfo +import com.grab.grazel.gradle.GradleProjectInfo import com.grab.grazel.gradle.MigrationChecker import com.grab.grazel.gradle.dependencies.DefaultDependencyResolutionService import com.grab.grazel.migrate.internal.RootBazelFileBuilder @@ -49,7 +51,8 @@ internal open class GenerateRootBazelScriptsTask constructor( private val migrationChecker: Lazy, private val workspaceBuilderFactory: Lazy, - private val rootBazelBuilder: Lazy, + private val rootBazelBuilderFactory: Lazy, + private val gradleProjectInfoFactory: Lazy, objectFactory: ObjectFactory, layout: ProjectLayout ) : DefaultTask() { @@ -77,18 +80,23 @@ constructor( val projectsToMigrate = rootProject .subprojects .filter { migrationChecker.get().canMigrate(it) } + val workspaceDependencies = dependencyResolutionService + .get() + .get(workspaceDependencies.get().asFile) - workspaceBuilderFactory.get() - .create( - projectsToMigrate = projectsToMigrate, - workspaceDependencies = dependencyResolutionService - .get() - .get(workspaceDependencies.get().asFile) - ).build() - .writeToFile(workspaceFile.get().asFile) + val gradleProjectInfo: GradleProjectInfo = gradleProjectInfoFactory.get() + .create(workspaceDependencies) + + workspaceBuilderFactory.get().create( + projectsToMigrate = projectsToMigrate, + gradleProjectInfo = gradleProjectInfo, + workspaceDependencies = workspaceDependencies + ).build().writeToFile(workspaceFile.get().asFile) logger.quiet("Generated WORKSPACE".ansiGreen) - val rootBuildBazelContents = rootBazelBuilder.get().build() + val rootBuildBazelContents = rootBazelBuilderFactory.get() + .create(gradleProjectInfo) + .build() if (rootBuildBazelContents.isNotEmpty()) { rootBuildBazelContents.writeToFile(buildBazel.get().asFile) logger.quiet("Generated $BUILD_BAZEL".ansiGreen) @@ -106,7 +114,8 @@ constructor( TASK_NAME, grazelComponent.migrationChecker(), grazelComponent.workspaceBuilderFactory(), - grazelComponent.rootBazelFileBuilder(), + grazelComponent.rootBazelFileFactory(), + grazelComponent.gradleProjectInfoFactory(), rootProject.objects, rootProject.layout ).apply { diff --git a/maven_install.json b/maven_install.json index 0467ef60..63bd6b37 100644 --- a/maven_install.json +++ b/maven_install.json @@ -2,7 +2,7 @@ "dependency_tree": { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", "__INPUT_ARTIFACTS_HASH": 1483382249, - "__RESOLVED_ARTIFACTS_HASH": 125425482, + "__RESOLVED_ARTIFACTS_HASH": 458120262, "conflict_resolution": { "androidx.annotation:annotation:1.5.0": "androidx.annotation:annotation:1.6.0" }, @@ -506,17 +506,17 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/maven.google.com/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar", + "file": "v1/https/dl.google.com/dl/android/maven2/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar", "mirror_urls": [ - "https://maven.google.com/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar", "https://dl.google.com/dl/android/maven2/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar", "https://repo.maven.apache.org/maven2/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar", + "https://maven.google.com/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar", "https://repo1.maven.org/maven2/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar", "https://oss.sonatype.org/content/repositories/snapshots/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar" ], "packages": [], "sha256": "c9468f56e05006ea151a426c54957cd0799b8b83a579d2846dd22061f33e5ecd", - "url": "https://maven.google.com/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar" + "url": "https://dl.google.com/dl/android/maven2/androidx/autofill/autofill/1.0.0/autofill-1.0.0.aar" }, { "coord": "androidx.collection:collection:1.1.0", @@ -1787,17 +1787,17 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/maven.google.com/androidx/fragment/fragment/1.3.6/fragment-1.3.6.aar", + "file": "v1/https/dl.google.com/dl/android/maven2/androidx/fragment/fragment/1.3.6/fragment-1.3.6.aar", "mirror_urls": [ - "https://maven.google.com/androidx/fragment/fragment/1.3.6/fragment-1.3.6.aar", "https://dl.google.com/dl/android/maven2/androidx/fragment/fragment/1.3.6/fragment-1.3.6.aar", "https://repo.maven.apache.org/maven2/androidx/fragment/fragment/1.3.6/fragment-1.3.6.aar", + "https://maven.google.com/androidx/fragment/fragment/1.3.6/fragment-1.3.6.aar", "https://repo1.maven.org/maven2/androidx/fragment/fragment/1.3.6/fragment-1.3.6.aar", "https://oss.sonatype.org/content/repositories/snapshots/androidx/fragment/fragment/1.3.6/fragment-1.3.6.aar" ], "packages": [], "sha256": "12f0831b4f08092d5dda272c1923c11a022ff20ceffed3e801751e21bb8d1c1e", - "url": "https://maven.google.com/androidx/fragment/fragment/1.3.6/fragment-1.3.6.aar" + "url": "https://dl.google.com/dl/android/maven2/androidx/fragment/fragment/1.3.6/fragment-1.3.6.aar" }, { "coord": "androidx.interpolator:interpolator:1.0.0", @@ -2750,12 +2750,12 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", + "file": "v1/https/repo.maven.apache.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", - "https://dl.google.com/dl/android/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", "https://repo.maven.apache.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", + "https://dl.google.com/dl/android/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", "https://maven.google.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", + "https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", "https://oss.sonatype.org/content/repositories/snapshots/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" ], "packages": [ @@ -2764,7 +2764,7 @@ "javax.annotation.meta" ], "sha256": "766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7", - "url": "https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" + "url": "https://repo.maven.apache.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" }, { "coord": "com.google.dagger:dagger-compiler:2.47", @@ -3028,12 +3028,12 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar", + "file": "v1/https/repo.maven.apache.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar", - "https://dl.google.com/dl/android/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar", "https://repo.maven.apache.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar", + "https://dl.google.com/dl/android/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar", "https://maven.google.com/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar", + "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar", "https://oss.sonatype.org/content/repositories/snapshots/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar" ], "packages": [ @@ -3041,7 +3041,7 @@ "com.google.errorprone.annotations.concurrent" ], "sha256": "cd5257c08a246cf8628817ae71cb822be192ef91f6881ca4a3fcff4f1de1cff3", - "url": "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar" + "url": "https://repo.maven.apache.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar" }, { "coord": "com.google.errorprone:javac-shaded:9-dev-r4023-3", @@ -3050,12 +3050,12 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar", + "file": "v1/https/repo.maven.apache.org/maven2/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar", - "https://dl.google.com/dl/android/maven2/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar", "https://repo.maven.apache.org/maven2/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar", + "https://dl.google.com/dl/android/maven2/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar", "https://maven.google.com/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar", + "https://repo1.maven.org/maven2/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar", "https://oss.sonatype.org/content/repositories/snapshots/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar" ], "packages": [ @@ -3096,7 +3096,7 @@ "org.openjdk.tools.sjavac.server.log" ], "sha256": "65bfccf60986c47fbc17c9ebab0be626afc41741e0a6ec7109e0768817a36f30", - "url": "https://repo1.maven.org/maven2/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar" + "url": "https://repo.maven.apache.org/maven2/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar" }, { "coord": "com.google.googlejavaformat:google-java-format:1.5", @@ -3111,12 +3111,12 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar", + "file": "v1/https/repo.maven.apache.org/maven2/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar", - "https://dl.google.com/dl/android/maven2/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar", "https://repo.maven.apache.org/maven2/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar", + "https://dl.google.com/dl/android/maven2/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar", "https://maven.google.com/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar", + "https://repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar", "https://oss.sonatype.org/content/repositories/snapshots/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar" ], "packages": [ @@ -3126,7 +3126,7 @@ "com.google.googlejavaformat.java.javadoc" ], "sha256": "aa19ad7850fb85178aa22f2fddb163b84d6ce4d0035872f30d4408195ca1144e", - "url": "https://repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar" + "url": "https://repo.maven.apache.org/maven2/com/google/googlejavaformat/google-java-format/1.5/google-java-format-1.5.jar" }, { "coord": "com.google.guava:failureaccess:1.0.1", @@ -3135,19 +3135,19 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", + "file": "v1/https/repo.maven.apache.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", - "https://dl.google.com/dl/android/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", "https://repo.maven.apache.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", + "https://dl.google.com/dl/android/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", "https://maven.google.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", + "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", "https://oss.sonatype.org/content/repositories/snapshots/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" ], "packages": [ "com.google.common.util.concurrent.internal" ], "sha256": "a171ee4c734dd2da837e4b16be9df4661afab72a41adaf31eb84dfdaf936ca26", - "url": "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" + "url": "https://repo.maven.apache.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" }, { "coord": "com.google.guava:guava:31.0.1-jre", @@ -3170,12 +3170,12 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar", + "file": "v1/https/repo.maven.apache.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar", - "https://dl.google.com/dl/android/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar", "https://repo.maven.apache.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar", + "https://dl.google.com/dl/android/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar", "https://maven.google.com/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar", + "https://repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar", "https://oss.sonatype.org/content/repositories/snapshots/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar" ], "packages": [ @@ -3199,7 +3199,7 @@ "com.google.thirdparty.publicsuffix" ], "sha256": "d5be94d65e87bd219fb3193ad1517baa55a3b88fc91d21cf735826ab5af087b9", - "url": "https://repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar" + "url": "https://repo.maven.apache.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar" }, { "coord": "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", @@ -3208,17 +3208,17 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", + "file": "v1/https/repo.maven.apache.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", - "https://dl.google.com/dl/android/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", "https://repo.maven.apache.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", + "https://dl.google.com/dl/android/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", "https://maven.google.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", + "https://repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", "https://oss.sonatype.org/content/repositories/snapshots/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" ], "packages": [], "sha256": "b372a037d4230aa57fbeffdef30fd6123f9c0c2db85d0aced00c91b974f33f99", - "url": "https://repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" + "url": "https://repo.maven.apache.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" }, { "coord": "com.google.j2objc:j2objc-annotations:1.3", @@ -3227,19 +3227,19 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", + "file": "v1/https/repo.maven.apache.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", - "https://dl.google.com/dl/android/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", "https://repo.maven.apache.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", + "https://dl.google.com/dl/android/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", "https://maven.google.com/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", + "https://repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", "https://oss.sonatype.org/content/repositories/snapshots/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" ], "packages": [ "com.google.j2objc.annotations" ], "sha256": "21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b", - "url": "https://repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" + "url": "https://repo.maven.apache.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" }, { "coord": "com.squareup:javapoet:1.13.0", @@ -3248,19 +3248,19 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar", + "file": "v1/https/repo.maven.apache.org/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar", - "https://dl.google.com/dl/android/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar", "https://repo.maven.apache.org/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar", + "https://dl.google.com/dl/android/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar", "https://maven.google.com/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar", + "https://repo1.maven.org/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar", "https://oss.sonatype.org/content/repositories/snapshots/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar" ], "packages": [ "com.squareup.javapoet" ], "sha256": "4c7517e848a71b36d069d12bb3bf46a70fd4cda3105d822b0ed2e19c00b69291", - "url": "https://repo1.maven.org/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar" + "url": "https://repo.maven.apache.org/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.jar" }, { "coord": "com.squareup:kotlinpoet:1.11.0", @@ -3276,12 +3276,12 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar", + "file": "v1/https/repo.maven.apache.org/maven2/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar", - "https://dl.google.com/dl/android/maven2/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar", "https://repo.maven.apache.org/maven2/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar", + "https://dl.google.com/dl/android/maven2/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar", "https://maven.google.com/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar", + "https://repo1.maven.org/maven2/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar", "https://oss.sonatype.org/content/repositories/snapshots/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar" ], "packages": [ @@ -3290,7 +3290,7 @@ "com.squareup.kotlinpoet.tags" ], "sha256": "2887ada1ca03dd83baa2758640d87e840d1907564db0ef88d2289c868a980492", - "url": "https://repo1.maven.org/maven2/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar" + "url": "https://repo.maven.apache.org/maven2/com/squareup/kotlinpoet/1.11.0/kotlinpoet-1.11.0.jar" }, { "coord": "javax.inject:javax.inject:1", @@ -3376,12 +3376,12 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar", + "file": "v1/https/repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar", - "https://dl.google.com/dl/android/maven2/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar", "https://repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar", + "https://dl.google.com/dl/android/maven2/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar", "https://maven.google.com/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar", + "https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar", "https://oss.sonatype.org/content/repositories/snapshots/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar" ], "packages": [ @@ -3391,7 +3391,7 @@ "com.sun.jna.win32" ], "sha256": "5557e235a8aa2f9766d5dc609d67948f2a8832c2d796cea9ef1d6cbe0b3b7eaf", - "url": "https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar" + "url": "https://repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.6.0/jna-5.6.0.jar" }, { "coord": "net.ltgt.gradle.incap:incap:0.2", @@ -3400,19 +3400,19 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar", + "file": "v1/https/repo.maven.apache.org/maven2/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar", - "https://dl.google.com/dl/android/maven2/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar", "https://repo.maven.apache.org/maven2/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar", + "https://dl.google.com/dl/android/maven2/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar", "https://maven.google.com/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar", + "https://repo1.maven.org/maven2/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar", "https://oss.sonatype.org/content/repositories/snapshots/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar" ], "packages": [ "net.ltgt.gradle.incap" ], "sha256": "b625b9806b0f1e4bc7a2e3457119488de3cd57ea20feedd513db070a573a4ffd", - "url": "https://repo1.maven.org/maven2/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar" + "url": "https://repo.maven.apache.org/maven2/net/ltgt/gradle/incap/incap/0.2/incap-0.2.jar" }, { "coord": "org.checkerframework:checker-compat-qual:2.5.5", @@ -3421,19 +3421,19 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", + "file": "v1/https/repo.maven.apache.org/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", - "https://dl.google.com/dl/android/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", "https://repo.maven.apache.org/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", + "https://dl.google.com/dl/android/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", "https://maven.google.com/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", + "https://repo1.maven.org/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", "https://oss.sonatype.org/content/repositories/snapshots/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar" ], "packages": [ "org.checkerframework.checker.nullness.compatqual" ], "sha256": "11d134b245e9cacc474514d2d66b5b8618f8039a1465cdc55bbc0b34e0008b7a", - "url": "https://repo1.maven.org/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar" + "url": "https://repo.maven.apache.org/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar" }, { "coord": "org.checkerframework:checker-qual:3.12.0", @@ -3442,12 +3442,12 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar", + "file": "v1/https/repo.maven.apache.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar", - "https://dl.google.com/dl/android/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar", "https://repo.maven.apache.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar", + "https://dl.google.com/dl/android/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar", "https://maven.google.com/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar", + "https://repo1.maven.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar", "https://oss.sonatype.org/content/repositories/snapshots/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar" ], "packages": [ @@ -3482,7 +3482,7 @@ "org.checkerframework.framework.qual" ], "sha256": "ff10785ac2a357ec5de9c293cb982a2cbb605c0309ea4cc1cb9b9bc6dbe7f3cb", - "url": "https://repo1.maven.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar" + "url": "https://repo.maven.apache.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar" }, { "coord": "org.hamcrest:hamcrest-core:1.3", @@ -3514,12 +3514,12 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar", + "file": "v1/https/repo.maven.apache.org/maven2/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar", - "https://dl.google.com/dl/android/maven2/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar", "https://repo.maven.apache.org/maven2/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar", + "https://dl.google.com/dl/android/maven2/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar", "https://maven.google.com/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar", + "https://repo1.maven.org/maven2/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar", "https://oss.sonatype.org/content/repositories/snapshots/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar" ], "packages": [ @@ -3527,7 +3527,7 @@ "gnu.trove.decorator" ], "sha256": "c5fd725bffab51846bf3c77db1383c60aaaebfe1b7fe2f00d23fe1b7df0a439d", - "url": "https://repo1.maven.org/maven2/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar" + "url": "https://repo.maven.apache.org/maven2/org/jetbrains/intellij/deps/trove4j/1.0.20200330/trove4j-1.0.20200330.jar" }, { "coord": "org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.8.10", @@ -4496,12 +4496,12 @@ "exclusions": [ "androidx.test.espresso:espresso-contrib" ], - "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar", + "file": "v1/https/repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar", - "https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar", "https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar", + "https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar", "https://maven.google.com/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar", + "https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar", "https://oss.sonatype.org/content/repositories/snapshots/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar" ], "packages": [ @@ -4569,7 +4569,7 @@ "kotlin.reflect.jvm.internal.pcollections" ], "sha256": "3277ac102ae17aad10a55abec75ff5696c8d109790396434b496e75087854203", - "url": "https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar" + "url": "https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.6.10/kotlin-reflect-1.6.10.jar" }, { "coord": "org.jetbrains.kotlin:kotlin-script-runtime:1.8.10", From 5121994fa36c33be35ee246911bd5333463cae44 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Wed, 1 Nov 2023 13:41:27 +0800 Subject: [PATCH 2/3] Fix tests --- .../AndroidWorkspaceRepositoriesTest.kt | 31 +++++-- .../grazel/migrate/DaggerWorkspaceRuleTest.kt | 40 +++++++-- .../migrate/KotlinRootBazelRulesTest.kt | 30 ++++--- .../migrate/KotlinWorkspaceRulesTest.kt | 33 ++++---- .../dependencies/WorkspaceArtifactsTest.kt | 84 ------------------- .../test/kotlin/com/grab/grazel/util/Truth.kt | 4 +- 6 files changed, 91 insertions(+), 131 deletions(-) delete mode 100644 grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/dependencies/WorkspaceArtifactsTest.kt diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/AndroidWorkspaceRepositoriesTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/AndroidWorkspaceRepositoriesTest.kt index cbab6e21..3baf04ad 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/AndroidWorkspaceRepositoriesTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/AndroidWorkspaceRepositoriesTest.kt @@ -25,6 +25,7 @@ import com.grab.grazel.bazel.starlark.asString import com.grab.grazel.bazel.starlark.statements import com.grab.grazel.buildProject import com.grab.grazel.gradle.ANDROID_APPLICATION_PLUGIN +import com.grab.grazel.gradle.dependencies.model.WorkspaceDependencies import com.grab.grazel.util.createGrazelComponent import com.grab.grazel.util.doEvaluate import org.gradle.api.Project @@ -36,11 +37,15 @@ class AndroidWorkspaceRepositoriesTest : GrazelPluginTest() { @Test fun `assert android sdk repository is generated based on values from android binary target`() { val buildRootProject = buildRootProject() - val workspaceBuilder = buildRootProject - .createGrazelComponent() + val grazelComponent = buildRootProject.createGrazelComponent() + val gradleProjectInfo = grazelComponent.gradleProjectInfoFactory().get() + val workspaceBuilder = grazelComponent .workspaceBuilderFactory() .get() - .create(listOf(buildRootProject)) + .create( + listOf(buildRootProject), + gradleProjectInfo.create(WorkspaceDependencies(emptyMap())), + ) val generatedCode = statements { workspaceBuilder.addAndroidSdkRepositories(this) @@ -56,11 +61,15 @@ class AndroidWorkspaceRepositoriesTest : GrazelPluginTest() { @Test fun `assert android ndk repository is generated with empty path values`() { val buildRootProject = buildRootProject() - val workspaceBuilder = buildRootProject - .createGrazelComponent() + val grazelComponent = buildRootProject.createGrazelComponent() + val gradleProjectInfo = grazelComponent.gradleProjectInfoFactory().get() + val workspaceBuilder = grazelComponent .workspaceBuilderFactory() .get() - .create(listOf(buildRootProject)) + .create( + listOf(buildRootProject), + gradleProjectInfo.create(WorkspaceDependencies(emptyMap())), + ) val generatedCode = statements { workspaceBuilder.addAndroidSdkRepositories(this) }.asString() @@ -77,11 +86,15 @@ class AndroidWorkspaceRepositoriesTest : GrazelPluginTest() { val buildRootProject = buildRootProject { android.ndkApiLevel = ndkApiLevel } - val workspaceBuilder = buildRootProject - .createGrazelComponent() + val grazelComponent = buildRootProject.createGrazelComponent() + val gradleProjectInfo = grazelComponent.gradleProjectInfoFactory().get() + val workspaceBuilder = grazelComponent .workspaceBuilderFactory() .get() - .create(listOf(buildRootProject)) + .create( + listOf(buildRootProject), + gradleProjectInfo.create(WorkspaceDependencies(emptyMap())), + ) val generatedCode = statements { workspaceBuilder.addAndroidSdkRepositories(this) }.asString() diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/DaggerWorkspaceRuleTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/DaggerWorkspaceRuleTest.kt index 8246893e..506785a7 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/DaggerWorkspaceRuleTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/DaggerWorkspaceRuleTest.kt @@ -17,15 +17,19 @@ package com.grab.grazel.migrate import com.android.build.gradle.LibraryExtension -import com.google.common.truth.Truth import com.grab.grazel.GrazelExtension import com.grab.grazel.bazel.starlark.asString import com.grab.grazel.buildProject -import com.grab.grazel.di.DaggerGrazelComponent +import com.grab.grazel.di.GrazelComponent import com.grab.grazel.gradle.ANDROID_LIBRARY_PLUGIN import com.grab.grazel.gradle.KOTLIN_ANDROID_PLUGIN +import com.grab.grazel.gradle.dependencies.model.ResolvedDependency +import com.grab.grazel.gradle.dependencies.model.WorkspaceDependencies import com.grab.grazel.migrate.internal.WorkspaceBuilder +import com.grab.grazel.util.addGrazelExtension +import com.grab.grazel.util.createGrazelComponent import com.grab.grazel.util.doEvaluate +import com.grab.grazel.util.truth import org.gradle.api.Project import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies @@ -37,13 +41,14 @@ class DaggerWorkspaceRuleTest { private lateinit var rootProject: Project private lateinit var subProject: Project + private lateinit var grazelComponent: GrazelComponent private lateinit var workspaceFactory: WorkspaceBuilder.Factory @Before fun setup() { rootProject = buildProject("root") - rootProject.extensions.add(GrazelExtension.GRAZEL_EXTENSION, GrazelExtension(rootProject)) - val grazelComponent = DaggerGrazelComponent.factory().create(rootProject) + grazelComponent = rootProject.createGrazelComponent() + rootProject.addGrazelExtension() workspaceFactory = grazelComponent.workspaceBuilderFactory().get() subProject = buildProject("subproject", rootProject) @@ -69,6 +74,9 @@ class DaggerWorkspaceRuleTest { // Given val daggerTag = "2.37" val daggerSha = "0f001ed38ed4ebc6f5c501c20bd35a68daf01c8dbd7541b33b7591a84fcc7b1c" + subProject.repositories { + mavenCentral() + } subProject.dependencies { add("implementation", "com.google.dagger:dagger:$daggerTag") } @@ -84,13 +92,27 @@ class DaggerWorkspaceRuleTest { } // When - val workspaceStatements = workspaceFactory - .create(listOf(rootProject, subProject)) - .build() - .asString() + val workspaceDependencies = WorkspaceDependencies( + mapOf( + "default" to listOf( + ResolvedDependency.fromId( + "com.google.dagger:dagger:$daggerTag", + "MavenRepo" + ) + ) + ) + ) + val workspaceStatements = workspaceFactory.create( + projectsToMigrate = listOf(rootProject, subProject), + gradleProjectInfo = grazelComponent + .gradleProjectInfoFactory() + .get() + .create(workspaceDependencies), + workspaceDependencies = workspaceDependencies + ).build().asString() // Then - Truth.assertThat(workspaceStatements.removeSpaces()).apply { + workspaceStatements.removeSpaces().truth { contains( """load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES")""".removeSpaces() ) diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/KotlinRootBazelRulesTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/KotlinRootBazelRulesTest.kt index 8df55682..bdf434e6 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/KotlinRootBazelRulesTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/KotlinRootBazelRulesTest.kt @@ -16,14 +16,16 @@ package com.grab.grazel.migrate -import com.google.common.truth.Truth import com.grab.grazel.GrazelExtension import com.grab.grazel.bazel.starlark.asString import com.grab.grazel.buildProject -import com.grab.grazel.di.DaggerGrazelComponent import com.grab.grazel.gradle.ANDROID_LIBRARY_PLUGIN import com.grab.grazel.gradle.KOTLIN_ANDROID_PLUGIN +import com.grab.grazel.gradle.dependencies.model.WorkspaceDependencies import com.grab.grazel.migrate.internal.RootBazelFileBuilder +import com.grab.grazel.util.addGrazelExtension +import com.grab.grazel.util.createGrazelComponent +import com.grab.grazel.util.truth import org.gradle.api.Project import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies @@ -39,11 +41,14 @@ class KotlinRootBazelRulesTest { @Before fun setup() { rootProject = buildProject("root") - rootProject.extensions.add(GrazelExtension.GRAZEL_EXTENSION, GrazelExtension(rootProject)) - rootBazelFileBuilder = DaggerGrazelComponent - .factory() - .create(rootProject) - .rootBazelFileBuilder().get() + val grazelComponent = rootProject.createGrazelComponent() + rootProject.addGrazelExtension() + rootBazelFileBuilder = grazelComponent.rootBazelFileFactory() + .get() + .create( + gradleProjectInfo = grazelComponent.gradleProjectInfoFactory().get() + .create(WorkspaceDependencies(emptyMap())) + ) subProject = buildProject("subproject", rootProject) subProject.run { @@ -63,12 +68,11 @@ class KotlinRootBazelRulesTest { @Test fun `assert by default custom toolchain is not registered in root BUILD`() { - rootProject.configure { - // Default setup - } val rootBazelFileContents = rootBazelFileBuilder.build().asString() - Truth.assertThat(rootBazelFileContents).doesNotContain("define_kt_toolchain") - Truth.assertThat(rootBazelFileContents).doesNotContain("kt_kotlinc_options") + rootBazelFileContents.truth { + doesNotContain("define_kt_toolchain") + doesNotContain("kt_kotlinc_options") + } } @Test @@ -93,7 +97,7 @@ class KotlinRootBazelRulesTest { } } val rootBazelFileContents = rootBazelFileBuilder.build().asString() - Truth.assertThat(rootBazelFileContents).apply { + rootBazelFileContents.truth { // Kotlin compiler options contains( """kt_kotlinc_options( diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/KotlinWorkspaceRulesTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/KotlinWorkspaceRulesTest.kt index a8ff5d80..1c4c94b5 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/KotlinWorkspaceRulesTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/KotlinWorkspaceRulesTest.kt @@ -16,14 +16,16 @@ package com.grab.grazel.migrate -import com.google.common.truth.Truth import com.grab.grazel.GrazelExtension import com.grab.grazel.bazel.starlark.asString import com.grab.grazel.buildProject -import com.grab.grazel.di.DaggerGrazelComponent +import com.grab.grazel.di.GrazelComponent import com.grab.grazel.gradle.ANDROID_LIBRARY_PLUGIN import com.grab.grazel.gradle.KOTLIN_ANDROID_PLUGIN +import com.grab.grazel.gradle.dependencies.model.WorkspaceDependencies import com.grab.grazel.migrate.internal.WorkspaceBuilder +import com.grab.grazel.util.addGrazelExtension +import com.grab.grazel.util.createGrazelComponent import com.grab.grazel.util.truth import org.gradle.api.Project import org.gradle.kotlin.dsl.configure @@ -35,13 +37,14 @@ class KotlinWorkspaceRulesTest { private lateinit var rootProject: Project private lateinit var subProject: Project + private lateinit var grazelComponent: GrazelComponent private lateinit var workspaceFactory: WorkspaceBuilder.Factory @Before fun setup() { rootProject = buildProject("root") - rootProject.extensions.add(GrazelExtension.GRAZEL_EXTENSION, GrazelExtension(rootProject)) - val grazelComponent = DaggerGrazelComponent.factory().create(rootProject) + grazelComponent = rootProject.createGrazelComponent() + rootProject.addGrazelExtension() workspaceFactory = grazelComponent.workspaceBuilderFactory().get() subProject = buildProject("subproject", rootProject) @@ -67,11 +70,7 @@ class KotlinWorkspaceRulesTest { sha = kotlinSha } } - val workspaceStatements = workspaceFactory - .create(listOf(rootProject, subProject)) - .build() - .asString() - workspaceStatements.truth().apply { + generateWorkspace().truth { // Default http archive contains( """http_archive( @@ -110,9 +109,7 @@ class KotlinWorkspaceRulesTest { } } } - val workspaceStatements = - workspaceFactory.create(listOf(rootProject, subProject)).build().asString() - Truth.assertThat(workspaceStatements).apply { + generateWorkspace().truth { contains( """git_repository( name = "io_bazel_rules_kotlin", @@ -134,11 +131,17 @@ class KotlinWorkspaceRulesTest { } } } - val workspaceStatements = - workspaceFactory.create(listOf(rootProject, subProject)).build().asString() - Truth.assertThat(workspaceStatements).apply { + generateWorkspace().truth { contains("""register_toolchains("//:kotlin_toolchain")""") doesNotContain("kt_register_toolchains()") } } + + fun generateWorkspace() = workspaceFactory + .create( + projectsToMigrate = listOf(rootProject, subProject), + gradleProjectInfo = grazelComponent.gradleProjectInfoFactory().get() + .create(WorkspaceDependencies(emptyMap())) + ).build() + .asString() } \ No newline at end of file diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/dependencies/WorkspaceArtifactsTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/dependencies/WorkspaceArtifactsTest.kt deleted file mode 100644 index 600bd589..00000000 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/dependencies/WorkspaceArtifactsTest.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2022 Grabtaxi Holdings PTE LTD (GRAB) - * - * Licensed 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. - */ - -package com.grab.grazel.migrate.dependencies - -import com.android.build.gradle.AppExtension -import com.google.common.truth.Truth -import com.grab.grazel.GrazelExtension -import com.grab.grazel.GrazelPluginTest -import com.grab.grazel.bazel.starlark.asString -import com.grab.grazel.buildProject -import com.grab.grazel.gradle.ANDROID_APPLICATION_PLUGIN -import com.grab.grazel.util.addGrazelExtension -import com.grab.grazel.util.createGrazelComponent -import com.grab.grazel.util.doEvaluate -import org.gradle.api.Project -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.repositories -import org.junit.Ignore -import org.junit.Test - -class WorkspaceArtifactsTest : GrazelPluginTest() { - - @Test - @Ignore("No longer required due to transitive resolution implemented in variant aware migration") - fun `assert artifact versions are overridden with overrideArtifactVersions`() { - val overrideArtifactVersion = "org.jacoco:org.jacoco.ant:7.7.7" - val (rootProject, androidBinary) = buildAndroidProject { - dependencies { - overrideArtifactVersions.add(overrideArtifactVersion) - } - } - val workspaceBuilder = rootProject - .createGrazelComponent() - .workspaceBuilderFactory() - .get() - .create(listOf(rootProject, androidBinary)) - val workspace = workspaceBuilder - .build() - .asString() - - Truth.assertThat(workspace).apply { - contains(overrideArtifactVersion) - } - } - - private fun buildAndroidProject( - configure: GrazelExtension.() -> Unit = {}, - ): Pair { - val rootProject = buildProject("root") - rootProject.addGrazelExtension(configure) - val androidBinary = buildProject("android-binary", rootProject) - androidBinary.run { - plugins.apply { - apply(ANDROID_APPLICATION_PLUGIN) - } - extensions.configure { - defaultConfig { - compileSdkVersion(32) - buildToolsVersion("32.0.0") - } - } - repositories { - mavenCentral() - google() - } - doEvaluate() - } - return rootProject to androidBinary - } -} diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/util/Truth.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/util/Truth.kt index b5aae840..611f9a6b 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/util/Truth.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/util/Truth.kt @@ -2,6 +2,7 @@ package com.grab.grazel.util import com.google.common.truth.IterableSubject import com.google.common.truth.MapSubject +import com.google.common.truth.StringSubject import com.google.common.truth.Truth inline fun Collection<*>.truth( @@ -12,4 +13,5 @@ inline fun Map<*, *>.truth( assertions: MapSubject.() -> Unit = {} ): MapSubject = Truth.assertThat(this).apply(assertions) -fun String.truth() = Truth.assertThat(this) \ No newline at end of file +fun String.truth(block: StringSubject.() -> Unit = {}): StringSubject = + Truth.assertThat(this).apply(block) \ No newline at end of file From 467868ab1641799ba7f5c5795e15969032230f46 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Wed, 1 Nov 2023 13:45:50 +0800 Subject: [PATCH 3/3] Remove unused method --- .../gradle/dependencies/Dependencies.kt | 35 +------------------ 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/gradle/dependencies/Dependencies.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/gradle/dependencies/Dependencies.kt index d5c2d401..fb0c0728 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/gradle/dependencies/Dependencies.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/gradle/dependencies/Dependencies.kt @@ -47,7 +47,7 @@ import org.gradle.api.artifacts.ResolvedDependency import org.gradle.api.artifacts.component.ModuleComponentIdentifier import org.gradle.api.internal.artifacts.DefaultResolvedDependency import java.io.File -import java.util.TreeSet +import java.util.* import javax.inject.Inject import javax.inject.Singleton @@ -77,14 +77,6 @@ internal data class ArtifactsConfig( ) internal interface DependenciesDataSource { - /** - * Return the project's maven dependencies before the resolution strategy and any other custom substitution by Gradle - */ - fun mavenDependencies( - project: Project, - vararg buildGraphTypes: BuildGraphType - ): Sequence - /** * Return the project's project (module) dependencies before the resolution strategy and any other custom * substitutions by Gradle @@ -171,31 +163,6 @@ internal class DefaultDependenciesDataSource @Inject constructor( .any { MavenArtifact(it.moduleGroup, it.moduleName).isIgnored } } - override fun mavenDependencies( - project: Project, - vararg buildGraphTypes: BuildGraphType - ): Sequence { - return declaredDependencies( - project, - *buildGraphTypes.map { it.configurationScope }.toTypedArray() - ).filter { (configuration, _) -> - if (buildGraphTypes.isEmpty()) { - true - } else { - configurationDataSource.isThisConfigurationBelongsToThisVariants( - project, - *buildGraphTypes.map { it.variant }.toTypedArray(), - configuration = configuration - ) - } - }.map { it.second } - .filter { it.group != null && it.group !in IGNORED_ARTIFACT_GROUPS } - .filter { - val artifact = MavenArtifact(it.group, it.name) - !artifact.isExcluded && !artifact.isIgnored - }.filter { it !is ProjectDependency } - } - override fun projectDependencies( project: Project, vararg scopes: ConfigurationScope ) = declaredDependencies(project, *scopes)