Skip to content

Commit

Permalink
MBS-7970 remove :gradle:utils module (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsvoronin committed Nov 1, 2020
1 parent 3fbb024 commit dc86030
Show file tree
Hide file tree
Showing 42 changed files with 72 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ plugins {
}

dependencies {
api(project(":gradle:utils"))
api(project(":gradle:build-failer"))
}
9 changes: 9 additions & 0 deletions subprojects/gradle/build-failer/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id("kotlin")
`maven-publish`
id("com.jfrog.bintray")
}

dependencies {
api(gradleApi())
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.avito.utils

import org.gradle.api.Project

@Suppress("unused")
val Project.buildFailer: BuildFailer
get() = BuildFailer.RealFailer()

Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/build-metrics/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dependencies {
implementation(project(":gradle:sentry-config"))
implementation(project(":gradle:graphite-config"))
implementation(project(":gradle:statsd-config"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:kotlin-dsl-support"))
implementation(project(":gradle:impact-shared"))
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/build-properties/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dependencies {
implementation(Dependencies.Gradle.androidPlugin)

implementation(project(":gradle:pre-build"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:kotlin-dsl-support"))

Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/build-trace/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
}

dependencies {
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:kotlin-dsl-support"))
implementation(project(":gradle:trace-event"))
Expand Down
2 changes: 1 addition & 1 deletion subprojects/gradle/buildchecks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

dependencies {
implementation(project(":gradle:utils"))
implementation(project(":gradle:build-failer"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:android"))
implementation(project(":gradle:impact-shared"))
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/cd/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies {
implementation(project(":gradle:tms"))
implementation(project(":gradle:upload-cd-build-result"))
implementation(project(":gradle:upload-to-googleplay"))
implementation(project(":gradle:utils"))

testImplementation(project(":common:test-okhttp"))
testImplementation(project(":gradle:artifactory-app-backup-test-fixtures"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.avito.android.androidSdk
import com.avito.ci.steps.ArtifactsConfiguration
import com.avito.ci.steps.Output
import com.avito.plugin.SignVerifier
import com.avito.utils.exhaustive
import com.avito.utils.logging.ciLogger
import org.gradle.api.DefaultTask
import org.gradle.api.model.ObjectFactory
Expand Down Expand Up @@ -66,7 +65,7 @@ abstract class VerifyOutputsTask @Inject constructor(objects: ObjectFactory) : D
outputsVerifier.checkBundleSignature(it, output.signature!!)
}
}
}.exhaustive()
}
}

if (outputsVerifier.errors.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import com.avito.impact.configuration.internalModule
import com.avito.kotlin.dsl.typedNamed
import com.avito.plugin.signedApkTaskProvider
import com.avito.plugin.signedBundleTaskProvider
import com.avito.utils.exhaustive
import com.avito.utils.logging.ciLogger
import com.avito.utils.onBuildFailed
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.invocation.Gradle
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.register
Expand All @@ -27,7 +26,6 @@ open class VerifyArtifactsStep(

rootTask.configure { task ->
artifactsConfig.outputs.forEach { (_, output) ->
@Suppress("IMPLICIT_CAST_TO_ANY")
when (output) {
is Output.ApkOutput -> {
task.dependsOn(project.tasks.signedApkTaskProvider(output.variantName))
Expand All @@ -39,7 +37,7 @@ open class VerifyArtifactsStep(
is Output.FileOutput -> {
// do nothing
}
}.exhaustive()
}
}
}

Expand Down Expand Up @@ -78,3 +76,13 @@ open class VerifyArtifactsStep(
internal fun verifyTaskName(context: String) = "${context}VerifyArtifacts"

internal fun TaskContainer.verifyTaskProvider(context: String) = typedNamed<VerifyOutputsTask>(verifyTaskName(context))

private fun Gradle.onBuildFailed(block: () -> Unit) {
buildFinished { buildResult ->
if (buildResult.failure != null && buildResult.action == ACTION_BUILD) {
block()
}
}
}

private const val ACTION_BUILD = "Build"
1 change: 0 additions & 1 deletion subprojects/gradle/code-ownership/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies {
implementation(project(":gradle:impact-shared"))
implementation(project(":gradle:module-types"))
implementation(project(":gradle:pre-build"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:kotlin-dsl-support"))

testImplementation(project(":gradle:test-project"))
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/design-screenshots/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ plugins {
dependencies {
implementation(project(":gradle:kotlin-dsl-support"))
implementation(project(":gradle:android"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:runner:service"))
implementation(project(":gradle:runner:shared"))
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/docker/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {
dependencies {
implementation(gradleApi())
implementation(project(":gradle:kotlin-dsl-support"))
implementation(project(":gradle:utils"))
implementation(Dependencies.funktionaleTry)
implementation(Dependencies.kotlinReflect)
// TODO: Use https://github.com/docker-java/docker-java
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/graphite-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dependencies {
api(project(":common:graphite"))

implementation(gradleApi())
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:kotlin-dsl-support"))
}
1 change: 0 additions & 1 deletion subprojects/gradle/impact-shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {

dependencies {
implementation(gradleApi())
implementation(project(":gradle:utils"))
implementation(project(":gradle:process"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:android"))
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/impact/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies {
project(":gradle:impact-shared")
)
implementation(gradleApi())
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:files"))
implementation(project(":gradle:android"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies {
implementation(project(":gradle:impact"))
implementation(project(":gradle:teamcity"))
implementation(project(":gradle:git"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:files"))
implementation(project(":gradle:sentry-config"))
Expand Down
4 changes: 2 additions & 2 deletions subprojects/gradle/instrumentation-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ dependencies {
implementation(project(":gradle:runner:client"))
implementation(project(":gradle:teamcity"))
implementation(project(":gradle:upload-cd-build-result"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:build-failer"))
implementation(project(":gradle:worker"))

testImplementation(project(":gradle:test-project"))
testImplementation(project(":gradle:logging-test-fixtures"))
testImplementation(project(":gradle:slack-test-fixtures"))
testImplementation(project(":gradle:utils-test-fixtures"))
testImplementation(project(":gradle:build-failer-test-fixtures"))
testImplementation(project(":gradle:instrumentation-tests-test-fixtures"))
testImplementation(project(":common:report-viewer-test-fixtures"))
testImplementation(Dependencies.Test.mockitoKotlin)
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/lint-report/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dependencies {
implementation(Dependencies.okhttp)

implementation(project(":gradle:android"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":common:okhttp"))
implementation(project(":gradle:impact-shared"))
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/module-types/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {

dependencies {
implementation(project(":gradle:impact-shared"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:pre-build"))
implementation(project(":gradle:kotlin-dsl-support"))
implementation(project(":gradle:impact"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
}

dependencies {
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:android"))
implementation(project(":gradle:impact"))
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/prosector/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
}

dependencies {
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:android"))
implementation(project(":gradle:kotlin-dsl-support"))
Expand Down
2 changes: 1 addition & 1 deletion subprojects/gradle/qapps/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
implementation(project(":gradle:kotlin-dsl-support"))
implementation(project(":gradle:android"))
implementation(project(":common:okhttp"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:build-failer"))
implementation(project(":gradle:ci-logger"))
implementation(project(":common:logger"))
implementation(Dependencies.funktionaleTry)
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/runner/service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies {
compileOnly(gradleApi())
api(project(":common:coroutines-extension"))
implementation(project(":gradle:runner:shared"))
implementation(project(":gradle:utils"))
implementation(Dependencies.funktionaleTry)
implementation(Dependencies.AndroidTest.ddmlib)
implementation(Dependencies.rxJava)
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/sentry-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dependencies {

implementation(gradleApi())
implementation(project(":common:okhttp"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:git"))
implementation(project(":gradle:kotlin-dsl-support"))
implementation(Dependencies.funktionaleTry)
Expand Down
3 changes: 1 addition & 2 deletions subprojects/gradle/signer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

dependencies {
implementation(project(":gradle:kotlin-dsl-support"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:build-failer"))
implementation(project(":gradle:ci-logger"))
implementation(project(":common:okhttp"))
implementation(project(":common:throwable-utils"))
Expand All @@ -20,7 +20,6 @@ dependencies {
implementation(Dependencies.okhttpLogging)

testImplementation(project(":gradle:test-project"))
testImplementation(project(":gradle:utils"))
testImplementation(project(":common:test-okhttp"))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.avito.android.bundleTaskProvider
import com.avito.android.withAndroidApp
import com.avito.kotlin.dsl.getBooleanProperty
import com.avito.kotlin.dsl.hasTasks
import com.avito.utils.hasContent
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.execution.TaskExecutionGraph
Expand All @@ -20,6 +19,8 @@ import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dslx.closureOf
import org.gradle.util.Path
import java.io.File
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract

/**
* Подписываем apk при помощи собственного сервиса.
Expand Down Expand Up @@ -198,3 +199,14 @@ class SignServicePlugin : Plugin<Project> {
}
}
}

@OptIn(ExperimentalContracts::class)
private fun String?.hasContent(): Boolean {
contract {
returns(true) implies (this@hasContent != null)
}

if (isNullOrBlank()) return false
if (this == "null") return false
return true
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.avito.plugin

import com.avito.utils.*
import com.avito.utils.ExistingFile
import com.avito.utils.createOrClear
import com.avito.utils.getStackTraceString
import com.avito.utils.logging.CILogger
import com.avito.utils.toExisting
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okhttp3.Request
Expand Down Expand Up @@ -103,4 +106,28 @@ internal class SignViaServiceAction(
error("Sign service returned: ${this.code}, body: $stringBody")
}
}

private fun <T> retry(
retriesCount: Int,
delaySeconds: Long = 1,
attemptFailedHandler: (attempt: Int, throwable: Throwable) -> Unit = { _, _ -> },
actionFailedHandler: (throwable: Throwable) -> Unit = { },
block: (attempt: Int) -> T
): T {
var throwable: Throwable? = null

(1..retriesCount).forEach { attempt ->
try {
return block(attempt)
} catch (e: Throwable) {
throwable = e
attemptFailedHandler(attempt, e)
TimeUnit.SECONDS.sleep(delaySeconds)
}
}

actionFailedHandler(throwable!!)

throw throwable!!
}
}
1 change: 0 additions & 1 deletion subprojects/gradle/slack/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ plugins {
dependencies {
api(Dependencies.funktionaleTry)

implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":common:time"))
implementation(Dependencies.slackClient) { exclude(group = "com.squareup.okhttp3") }
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/statsd-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dependencies {
api(project(":common:statsd"))

implementation(gradleApi())
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:kotlin-dsl-support"))
}
1 change: 0 additions & 1 deletion subprojects/gradle/teamcity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dependencies {
api(project(":common:teamcity-common"))
implementation(gradleApi())
implementation(project(":gradle:kotlin-dsl-support"))
implementation(project(":gradle:utils"))

testImplementation(project(":gradle:test-project"))
}
1 change: 0 additions & 1 deletion subprojects/gradle/test-project/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dependencies {
api(gradleTestKit())

implementation(project(":gradle:process"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:android"))

implementation(Dependencies.kotlinReflect)
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/trace-event/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ plugins {

dependencies {
implementation(Dependencies.gson)
implementation(project(":gradle:utils"))
}
1 change: 0 additions & 1 deletion subprojects/gradle/upload-cd-build-result/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies {
implementation(Dependencies.okhttpLogging)
implementation(Dependencies.gson)

implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(project(":gradle:android"))
implementation(project(":gradle:kotlin-dsl-support"))
Expand Down
1 change: 0 additions & 1 deletion subprojects/gradle/upload-to-googleplay/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {

dependencies {
implementation(project(":gradle:kotlin-dsl-support"))
implementation(project(":gradle:utils"))
implementation(project(":gradle:ci-logger"))
implementation(gradleApi())
implementation(Dependencies.googlePublish)
Expand Down
Loading

0 comments on commit dc86030

Please sign in to comment.