Skip to content

Commit

Permalink
MBS-9952 Change dependencies from unsafe String to the type safe decl…
Browse files Browse the repository at this point in the history
…aration (#672)
  • Loading branch information
sboishtyan authored Dec 10, 2020
1 parent d632e64 commit 5159e3d
Show file tree
Hide file tree
Showing 21 changed files with 307 additions and 151 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.avito.android.plugin.build_param_check

import com.avito.test.gradle.TestProjectGenerator
import com.avito.test.gradle.dependencies.GradleDependency.Safe.Companion.project
import com.avito.test.gradle.gradlew
import com.avito.test.gradle.module.AndroidAppModule
import com.avito.test.gradle.module.AndroidLibModule
Expand All @@ -21,18 +22,18 @@ class UniqueRClassesTest {
AndroidAppModule(
name = "app-x",
packageName = "x",
dependencies = """
implementation project(':lib-a')
implementation project(':lib-b')
""".trimIndent()
dependencies = setOf(
project(":lib-a"),
project(":lib-b")
)
),
AndroidAppModule(
name = "app-y",
packageName = "y",
dependencies = """
implementation project(':lib-b')
implementation project(':lib-c')
""".trimIndent()
dependencies = setOf(
project(":lib-c"),
project(":lib-b")
)
),
AndroidLibModule(name = "lib-a", packageName = "a"),
AndroidLibModule(name = "lib-b", packageName = "b"),
Expand Down Expand Up @@ -65,18 +66,18 @@ class UniqueRClassesTest {
AndroidAppModule(
name = "app-x",
packageName = "x",
dependencies = """
implementation project(':lib-a')
implementation project(':lib-b')
""".trimIndent()
dependencies = setOf(
project(":lib-a"),
project(":lib-b")
)
),
AndroidAppModule(
name = "app-y",
packageName = "y",
dependencies = """
implementation project(':lib-b')
implementation project(':duplicate')
""".trimIndent()
dependencies = setOf(
project(":duplicate"),
project(":lib-b")
)
),
AndroidLibModule(name = "lib-a", packageName = "a"),
AndroidLibModule(name = "lib-b", packageName = "b"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.avito.android.plugin.artifactory.artifactoryUserParameterName
import com.avito.cd.uploadCdBuildResultTaskName
import com.avito.ci.steps.verifyTaskName
import com.avito.test.gradle.TestProjectGenerator
import com.avito.test.gradle.dependencies.GradleDependency.Safe.Companion.project
import com.avito.test.gradle.file
import com.avito.test.gradle.module.AndroidAppModule
import com.avito.test.gradle.module.AndroidLibModule
Expand Down Expand Up @@ -33,7 +34,7 @@ class CiStepsPluginTest {
modules = listOf(
AndroidAppModule(
name = "appA",
dependencies = "implementation project(':shared')",
dependencies = setOf(project(":shared")),
plugins = listOf(
"com.avito.android.signer",
"com.avito.android.instrumentation-tests",
Expand Down Expand Up @@ -102,12 +103,12 @@ class CiStepsPluginTest {
),
AndroidAppModule(
name = "appB",
dependencies = "implementation project(':shared')",
dependencies = setOf(project(":shared")),
plugins = listOf("com.avito.android.cd")
),
AndroidLibModule(
name = "shared",
dependencies = "implementation project(':transitive')"
dependencies = setOf(project(":transitive"))
),
AndroidLibModule(
name = "transitive"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.avito.ci

import com.avito.test.gradle.TestProjectGenerator
import com.avito.test.gradle.dependencies.GradleDependency
import com.avito.test.gradle.dependencies.GradleDependency.Safe.Companion.project
import com.avito.test.gradle.module.AndroidAppModule
import com.avito.test.gradle.module.AndroidLibModule
import java.io.File
Expand All @@ -11,15 +13,15 @@ internal fun generateProjectWithImpactAnalysis(rootDir: File) {
modules = listOf(
appModule(
"appA",
dependencies = "implementation project(':shared')"
dependencies = setOf(project(":shared"))
),
appModule(
"appB",
dependencies = "implementation project(':shared')"
dependencies = setOf(project(":shared"))
),
AndroidLibModule(
name = "shared",
dependencies = "implementation project(':transitive')"
dependencies = setOf(project(":transitive"))
),
AndroidLibModule(
name = "transitive"
Expand All @@ -32,7 +34,7 @@ internal fun generateProjectWithImpactAnalysis(rootDir: File) {
}

@Suppress("MaxLineLength")
private fun appModule(name: String, dependencies: String) = AndroidAppModule(
private fun appModule(name: String, dependencies: Set<GradleDependency>) = AndroidAppModule(
name = name,
dependencies = dependencies,
plugins = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.avito.android.CodeOwnershipValidationTest.Case.NegativeCase
import com.avito.android.CodeOwnershipValidationTest.Case.PositiveCase
import com.avito.test.gradle.ManualTempFolder
import com.avito.test.gradle.TestProjectGenerator
import com.avito.test.gradle.dependencies.GradleDependency.Safe.CONFIGURATION.ANDROID_TEST_IMPLEMENTATION
import com.avito.test.gradle.dependencies.GradleDependency.Safe.Companion.project
import com.avito.test.gradle.gradlew
import com.avito.test.gradle.module.AndroidAppModule
import com.avito.test.gradle.module.AndroidLibModule
Expand Down Expand Up @@ -93,16 +95,17 @@ class CodeOwnershipValidationTest {
AndroidAppModule(
"app",
plugins = listOf("com.avito.android.module-types"),
dependencies = """
androidTestImplementation project(':feature')
""".trimIndent()
dependencies = setOf(
project(
path = ":feature",
configuration = ANDROID_TEST_IMPLEMENTATION
)
)
),
AndroidLibModule(
"feature",
plugins = listOf("com.avito.android.module-types"),
dependencies = """
implementation project(":dependent_test_module")
""".trimIndent(),
dependencies = setOf(project(path = ":dependent_test_module")),
buildGradleExtra = """
ownership {
team '${case.featureOwnership.team}.${case.featureOwnership.team}'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.avito.android

import com.avito.test.gradle.TestProjectGenerator
import com.avito.test.gradle.dependencies.GradleDependency.Safe.CONFIGURATION.COMPILE
import com.avito.test.gradle.dependencies.GradleDependency.Safe.Companion.platformProject
import com.avito.test.gradle.gradlew
import com.avito.test.gradle.module.KotlinModule
import com.avito.test.gradle.module.PlatformModule
Expand All @@ -20,7 +22,12 @@ class PlatformDependencyTest {
modules = listOf(
KotlinModule(
"lib",
dependencies = "compile platform(project(':platform'))"
dependencies = setOf(
platformProject(
path = ":platform",
configuration = COMPILE
)
)
),
PlatformModule("platform")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package com.avito.impact
import com.avito.test.gradle.TestProjectGenerator
import com.avito.test.gradle.TestResult
import com.avito.test.gradle.commit
import com.avito.test.gradle.dependencies.GradleDependency.Safe.CONFIGURATION.ANDROID_TEST_IMPLEMENTATION
import com.avito.test.gradle.dependencies.GradleDependency.Safe.CONFIGURATION.API
import com.avito.test.gradle.dependencies.GradleDependency.Safe.CONFIGURATION.IMPLEMENTATION
import com.avito.test.gradle.dependencies.GradleDependency.Safe.CONFIGURATION.TEST_IMPLEMENTATION
import com.avito.test.gradle.dependencies.GradleDependency.Safe.Companion.platformProject
import com.avito.test.gradle.dependencies.GradleDependency.Safe.Companion.project
import com.avito.test.gradle.dir
import com.avito.test.gradle.file
import com.avito.test.gradle.git
Expand Down Expand Up @@ -178,10 +184,10 @@ class ImpactAnalysisTest {
AndroidAppModule("standalone_app"),
AndroidAppModule(
name = "app",
dependencies = """
implementation project(':feature_a')
implementation project(':feature_b')
"""
dependencies = setOf(
project(":feature_a"),
project(":feature_b")
)
),
AndroidLibModule("feature_a"),
AndroidLibModule("feature_b")
Expand Down Expand Up @@ -209,22 +215,22 @@ class ImpactAnalysisTest {
AndroidAppModule("standalone_app"),
AndroidAppModule(
name = "app",
dependencies = """
implementation project(':feature_a')
implementation project(':feature_b')
"""
dependencies = setOf(
project(":feature_a"),
project(":feature_b")
)
),
AndroidLibModule(
name = "feature_a",
dependencies = """
implementation project(':core')
"""
dependencies = setOf(
project(":core")
)
),
AndroidLibModule(
name = "feature_b",
dependencies = """
implementation project(':core')
"""
dependencies = setOf(
project(":core")
)
),
AndroidLibModule("core")
)
Expand All @@ -251,16 +257,16 @@ class ImpactAnalysisTest {
AndroidAppModule("standalone_app"),
AndroidAppModule(
name = "app",
dependencies = """
implementation project(':feature')
testImplementation project(':test_utils')
"""
dependencies = setOf(
project(path = ":feature", configuration = IMPLEMENTATION),
project(path = ":test_utils", configuration = TEST_IMPLEMENTATION)
)
),
AndroidLibModule(
name = "feature",
dependencies = """
testImplementation project(':test_utils')
"""
dependencies = setOf(
project(path = ":test_utils", configuration = TEST_IMPLEMENTATION)
)
),
AndroidLibModule("test_utils")
)
Expand All @@ -287,15 +293,16 @@ class ImpactAnalysisTest {
AndroidAppModule("standalone_app"),
AndroidAppModule(
name = "app",
dependencies = """
androidTestImplementation project(':android_test_utils')
"""
dependencies = setOf(
project(path = ":android_test_utils", configuration = ANDROID_TEST_IMPLEMENTATION)
)

),
AndroidLibModule(
name = "android_test_utils",
dependencies = """
implementation project(':core_test_utils')
"""
dependencies = setOf(
project(":core_test_utils")
)
),
AndroidLibModule("core_test_utils")
)
Expand Down Expand Up @@ -325,22 +332,22 @@ class ImpactAnalysisTest {
AndroidAppModule("standalone_app"),
AndroidAppModule(
name = "app",
dependencies = """
implementation project(':feature')
androidTestImplementation project(':android_test_feature')
"""
dependencies = setOf(
project(path = ":feature", configuration = IMPLEMENTATION),
project(path = ":android_test_feature", configuration = ANDROID_TEST_IMPLEMENTATION)
)
),
AndroidLibModule(
name = "feature",
dependencies = """
androidTestImplementation project(':android_test_feature')
"""
dependencies = setOf(
project(path = ":android_test_feature", configuration = ANDROID_TEST_IMPLEMENTATION)
)
),
AndroidLibModule(
name = "android_test_feature",
dependencies = """
implementation project(':feature')
"""
dependencies = setOf(
project(":feature")
)
)
)
)
Expand All @@ -366,16 +373,16 @@ class ImpactAnalysisTest {
AndroidAppModule("standalone_app"),
AndroidAppModule(
name = "app",
dependencies = """
api platform(project(':platform'))
implementation project(':feature')
"""
dependencies = setOf(
platformProject(path = ":platform", configuration = API),
project(path = ":feature", configuration = IMPLEMENTATION)
)
),
AndroidLibModule(
name = "feature",
dependencies = """
api platform(project(':platform'))
"""
dependencies = setOf(
platformProject(path = ":platform", configuration = API)
)
),
PlatformModule(name = "platform")
)
Expand Down Expand Up @@ -405,10 +412,10 @@ class ImpactAnalysisTest {
AndroidAppModule("standalone_app"),
AndroidAppModule(
name = "app",
dependencies = """
implementation project(':parent:feature1')
implementation project(':parent:feature2')
"""
dependencies = setOf(
project(":parent:feature1"),
project(":parent:feature2")
)
),
ParentGradleModule(
name = "parent",
Expand Down Expand Up @@ -446,9 +453,9 @@ class ImpactAnalysisTest {
AndroidAppModule("standalone_app"),
AndroidAppModule(
name = "app",
dependencies = """
implementation project(':feature')
"""
dependencies = setOf(
project(":feature")
)
),
AndroidLibModule(
"feature"
Expand Down Expand Up @@ -478,9 +485,9 @@ class ImpactAnalysisTest {
AndroidAppModule("standalone_app"),
AndroidAppModule(
name = "app",
dependencies = """
androidTestImplementation platform(project(':platform'))
"""
dependencies = setOf(
platformProject(path = ":platform", configuration = ANDROID_TEST_IMPLEMENTATION)
)
),
PlatformModule(name = "platform")
)
Expand Down
Loading

0 comments on commit 5159e3d

Please sign in to comment.