Skip to content

Commit

Permalink
MBS-10881 update to gradle 7.2
Browse files Browse the repository at this point in the history
https://docs.gradle.org/7.2-rc-2/release-notes.html

also update detekt to 1.18.0, because of kotlin 1.5 dependency
disable "ArgumentListWrapping" rule, different behavior
fix "ImportOrdering" rule

remove kotlinx-html dependency
  • Loading branch information
dsvoronin committed Aug 16, 2021
1 parent 1f10403 commit ed3396c
Show file tree
Hide file tree
Showing 27 changed files with 97 additions and 122 deletions.
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
root = true

# See conf/detekt.yml, values should be the same

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
max_line_length = 120

ij_kotlin_imports_layout = *, java.**, javax.**, kotlin.**, ^
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,6 @@ dependencyResolutionManagement {
includeGroup("com.google.testing.platform")
}
}
/**
* This repo is used for kotlinx-html:0.7.2 (transitive dependency of current Detekt version)
* The new version of Detekt uses kotlinx-html:0.7.3, which is available in mavenCentral repo,
* so this block would become unnecessary. For more information about maven.pkg.jetbrains.space, see
* https://github.com/kotlin/kotlinx.html/wiki/Getting-started
* TODO: Remove this block after MBS-11267
*/
exclusiveContent {
forRepository {
maven {
setUrlOrProxy(
artifactoryUrl = artifactoryUrl,
repositoryName = "jetbrains-kotlinx-html",
originalRepo = "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven"
)
}
}
filter {
includeModule("org.jetbrains.kotlinx", "kotlinx-html-jvm")
}
}
exclusiveContent {
forRepository {
maven {
Expand Down
4 changes: 2 additions & 2 deletions build-logic/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ group = "com.avito.android.buildlogic"

dependencies {
implementation("com.avito.android.buildlogic:kotlin")
implementation(libs.kotlinPlugin)
implementation(libs.androidGradlePlugin)
implementation(libs.kotlinGradle)
implementation(libs.androidGradle)
// workaround for https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
10 changes: 6 additions & 4 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import io.gitlab.arturbosch.detekt.Detekt

plugins {
base
// accessing version catalog here will be supported in grale 7.2
// https://github.com/gradle/gradle/pull/17394
id("io.gitlab.arturbosch.detekt") version "1.16.0"
// accessing version catalog here is blocked by IDE false-postive error
// https://youtrack.jetbrains.com/issue/KTIJ-19369
id("io.gitlab.arturbosch.detekt") version "1.18.0"
}

val detektAll = tasks.register<io.gitlab.arturbosch.detekt.Detekt>("detektAll") {
val detektAll = tasks.register<Detekt>("detektAll") {
description = "Runs over whole code base without the starting overhead for each module."
parallel = true
setSource(files(projectDir))
Expand Down
4 changes: 2 additions & 2 deletions build-logic/checks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {
group = "com.avito.android.buildlogic"

dependencies {
implementation(libs.gradleVersionsPlugin)
implementation(libs.detektPlugin)
implementation(libs.versionsGradle)
implementation(libs.detektGradle)
// workaround for https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
2 changes: 1 addition & 1 deletion build-logic/kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ group = "com.avito.android.buildlogic"

dependencies {
implementation("com.avito.android.buildlogic:testing")
implementation(libs.kotlinPlugin)
implementation(libs.kotlinGradle)
implementation(libs.nebulaIntegTest)
}
2 changes: 1 addition & 1 deletion build-logic/publication/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
group = "com.avito.android.buildlogic"

dependencies {
implementation(libs.androidGradlePlugin)
implementation(libs.androidGradle)
implementation(libs.okhttp)
implementation(libs.kotson)
}
4 changes: 2 additions & 2 deletions build-logic/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ plugins {
group = "com.avito.android.buildlogic"

dependencies {
implementation(libs.kotlinPlugin)
implementation(libs.kotlinGradle)
implementation(libs.nebulaIntegTest)
implementation(libs.gradleTestRetryPlugin)
implementation(libs.testRetryGradle)
// workaround for https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ val samplesWrapper by tasks.registering(Copy::class) {
tasks.withType<Wrapper> {
// sources unavailable with BIN until https://youtrack.jetbrains.com/issue/IDEA-231667 resolved
distributionType = Wrapper.DistributionType.ALL
gradleVersion = "7.1"
gradleVersion = "7.2-rc-3"

finalizedBy(subprojectsWrapper, samplesWrapper)
}
Expand Down
5 changes: 3 additions & 2 deletions conf/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ formatting:
active: false
AnnotationSpacing:
active: true
# todo fix and enable
ArgumentListWrapping:
active: true
active: false
# questionable rule; && and || goes to the end of line, instead of beginning a new line as we do right now
ChainWrapping:
active: false
Expand All @@ -281,7 +282,7 @@ formatting:
insertFinalNewLine: false
ImportOrdering:
active: true
layout: 'idea'
layout: '*,java.**,javax.**,kotlin.**,^'
# blocked by bugs: https://github.com/pinterest/ktlint/issues?q=is%3Aissue+is%3Aopen+Indentation
Indentation:
active: false
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ androidX = "1.0.0"
espresso = "3.4.0"
coroutines = "1.3.8"
androidXTest = "1.4.0"
detekt = "1.16.0"
detekt = "1.18.0"
buildTools = "30.0.3"
compileSdk = "30"
targetSdk = "29"
Expand All @@ -15,7 +15,7 @@ junit5 = "5.7.2"
junit5Platform = "1.7.2"

[libraries]
kotlinPlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinGradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinTestJUnit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
kotlinXCli = "org.jetbrains.kotlinx:kotlinx-cli:0.2.1"
kotlinStdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
Expand Down Expand Up @@ -43,7 +43,7 @@ retrofitConverterScalars = { module = "com.squareup.retrofit2:converter-scalars"
gson = "com.google.code.gson:gson:2.8.5"
kotson = "com.github.salomonbrys.kotson:kotson:2.5.0"

androidGradlePlugin = "com.android.tools.build:gradle:4.2.2"
androidGradle = "com.android.tools.build:gradle:4.2.2"
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidX" }
material = { module = "com.google.android.material:material", version.ref = "androidX" }
recyclerView = "androidx.recyclerview:recyclerview:1.1.0"
Expand Down Expand Up @@ -82,8 +82,8 @@ okhttpMock = "com.github.gmazzo:okhttp-mock:1.4.0"
kotlinTest = "io.kotlintest:kotlintest:2.0.7"
coroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
nebulaIntegTest = "com.netflix.nebula:nebula-project-plugin:8.0.0"
gradleTestRetryPlugin = "org.gradle:test-retry-gradle-plugin:1.3.1"
gradleVersionsPlugin = "com.github.ben-manes:gradle-versions-plugin:0.39.0"
testRetryGradle = "org.gradle:test-retry-gradle-plugin:1.3.1"
versionsGradle = "com.github.ben-manes:gradle-versions-plugin:0.39.0"
junitJupiterApi = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" }
junitJupiterEngine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" }
junitPlatformRunner = { module = "org.junit.platform:junit-platform-runner", version.ref = "junit5Platform" }
Expand All @@ -98,5 +98,5 @@ googlePublish = "com.google.apis:google-api-services-androidpublisher:v3-rev86-1
googleAuthLibrary = "com.google.auth:google-auth-library-oauth2-http:0.10.0"
jdgraphtCore = "org.jgrapht:jgrapht-core:1.5.1"

detektPlugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
detektGradle = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-rc-3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 3 additions & 12 deletions samples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,10 @@ buildscript {

/**
* workaround to load plugin classes once:
* ttps://youtrack.jetbrains.com/issue/KT-31643#focus=Comments-27-3510019.0-0
* https://youtrack.jetbrains.com/issue/KT-31643#focus=Comments-27-3510019.0-0
*/
@Suppress("UnstableApiUsage")
dependencies {

/**
* workaround till https://github.com/gradle/gradle/issues/16958 is resolved
* most likely gradle 7.2
*/
val libs = project.extensions.getByType<VersionCatalogsExtension>()
.named("libs") as org.gradle.accessors.dm.LibrariesForLibs

classpath(libs.androidGradlePlugin)
classpath(libs.kotlinPlugin)
classpath(libs.kotlinGradle)
classpath(libs.androidGradle)
}
}
2 changes: 1 addition & 1 deletion samples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-rc-3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class FailViewElement(

private lateinit var exception: Throwable

override val actions: Actions
get() = FailActions(interactionContext, super.actions, exception)

fun firstFail(exception: Throwable): ViewElement {
this.exception = exception
return this
Expand Down Expand Up @@ -65,7 +68,4 @@ class FailViewElement(
)
}
}

override val actions: Actions
get() = FailActions(interactionContext, super.actions, exception)
}
17 changes: 5 additions & 12 deletions subprojects/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
plugins {
// accessing version catalog here is blocked by IDE false-postive error
// https://youtrack.jetbrains.com/issue/KTIJ-19369
id("com.autonomousapps.dependency-analysis") version "0.74.0"
id("convention.dependency-updates")
id("convention.detekt")
Expand All @@ -8,20 +10,11 @@ buildscript {

/**
* workaround to load plugin classes once:
* ttps://youtrack.jetbrains.com/issue/KT-31643#focus=Comments-27-3510019.0-0
* https://youtrack.jetbrains.com/issue/KT-31643#focus=Comments-27-3510019.0-0
*/
@Suppress("UnstableApiUsage")
dependencies {

/**
* workaround till https://github.com/gradle/gradle/issues/16958 is resolved
* most likely gradle 7.2
*/
val libs = project.extensions.getByType<VersionCatalogsExtension>()
.named("libs") as org.gradle.accessors.dm.LibrariesForLibs

classpath(libs.androidGradlePlugin)
classpath(libs.kotlinPlugin)
classpath(libs.androidGradle)
classpath(libs.kotlinGradle)

/**
* com.autonomousapps.dependency-analysis depends on older version of okio, and it's resolved for
Expand Down
2 changes: 1 addition & 1 deletion subprojects/gradle/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

dependencies {
api(libs.androidGradlePlugin) {
api(libs.androidGradle) {
excludeTransitiveAgpDependencies()
}

Expand Down
2 changes: 1 addition & 1 deletion subprojects/gradle/build-checks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies {
implementation(projects.common.result)
implementation(projects.gradle.statsdConfig)
implementation(projects.gradle.gradleExtensions)
implementation(libs.kotlinPlugin)
implementation(libs.kotlinGradle)

// for test
implementation(projects.gradle.moduleTypes)
Expand Down
2 changes: 1 addition & 1 deletion subprojects/gradle/build-metrics/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies {
implementation(projects.gradle.gradleExtensions)
implementation(projects.gradle.statsdConfig)
implementation(projects.gradle.teamcity)
implementation(libs.kotlinPlugin)
implementation(libs.kotlinGradle)

testImplementation(libs.mockitoKotlin)
testImplementation(libs.mockitoJUnitJupiter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,6 @@ import java.io.File

internal class HttpBuildCacheMetricsTest : HttpBuildCacheTestFixture() {

override fun setupProject(projectDir: File) {
File(projectDir, "build.gradle.kts").writeText(
"""
plugins {
id("com.avito.android.build-metrics")
}
@CacheableTask
abstract class CustomTask @Inject constructor(objects: ObjectFactory) : DefaultTask() {
@Input
var input: Long = 0
@OutputFile
val outputFile = objects.fileProperty()
@TaskAction
fun createFile() {
outputFile.get().asFile.writeText("Output of CacheableTask: " + input)
}
}
tasks.register("cacheMissTask", CustomTask::class.java) {
input = System.currentTimeMillis()
outputFile.set(file("build/cacheMissTask.txt"))
}
""".trimIndent()
)
}

private class TestCase(
val name: String,
val loadStatus: Int,
val storeStatus: Int,
val assertion: (result: TestResult) -> Unit
)

private val cases = listOf(
TestCase(
name = "no errors - miss and successful store",
Expand Down Expand Up @@ -93,6 +56,43 @@ internal class HttpBuildCacheMetricsTest : HttpBuildCacheTestFixture() {
),
)

override fun setupProject(projectDir: File) {
File(projectDir, "build.gradle.kts").writeText(
"""
plugins {
id("com.avito.android.build-metrics")
}
@CacheableTask
abstract class CustomTask @Inject constructor(objects: ObjectFactory) : DefaultTask() {
@Input
var input: Long = 0
@OutputFile
val outputFile = objects.fileProperty()
@TaskAction
fun createFile() {
outputFile.get().asFile.writeText("Output of CacheableTask: " + input)
}
}
tasks.register("cacheMissTask", CustomTask::class.java) {
input = System.currentTimeMillis()
outputFile.set(file("build/cacheMissTask.txt"))
}
""".trimIndent()
)
}

private class TestCase(
val name: String,
val loadStatus: Int,
val storeStatus: Int,
val assertion: (result: TestResult) -> Unit
)

@TestFactory
fun `remote cache errors`(): List<DynamicTest> {
return cases.map { case ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import org.gradle.kotlin.dsl.support.uncheckedCast
*/
public fun <T> noOwnerClosureOf(action: T.() -> Unit): Closure<T> =
object : Closure<T>(null, null) {
@Suppress("unused") // to be called dynamically by Groovy
// to be called dynamically by Groovy
@Suppress("unused")
fun doCall() = uncheckedCast<T>(delegate).action()
}

Expand Down
Loading

0 comments on commit ed3396c

Please sign in to comment.