|
| 1 | +import kotlin.String |
| 2 | + |
| 3 | +// Shared versions |
| 4 | + |
| 5 | +private const val kotlinVersion = "1.3.72" |
| 6 | + |
| 7 | +/** |
| 8 | + * Gradle plugins used throughout the repository. |
| 9 | + * Also, the list of supported AGP versions is maintained here. |
| 10 | + */ |
| 11 | +object Plugins { |
| 12 | + // Maintenance & Build Environment |
| 13 | + const val versions: Lib = "com.github.ben-manes:gradle-versions-plugin:0.20.0" |
| 14 | + const val kotlin: Lib = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" |
| 15 | + |
| 16 | + // Android Gradle Plugin |
| 17 | + const val android35x: Agp = "com.android.tools.build:gradle:3.5.3" |
| 18 | + const val android36x: Agp = "com.android.tools.build:gradle:3.6.3" |
| 19 | + const val android40x: Agp = "com.android.tools.build:gradle:4.0.0-beta05" |
| 20 | + const val android41x: Agp = "com.android.tools.build:gradle:4.1.0-alpha08" |
| 21 | + const val android: Agp = android35x |
| 22 | + |
| 23 | + val supportedAndroidPlugins = listOf( |
| 24 | + android35x, |
| 25 | + android36x, |
| 26 | + android40x, |
| 27 | + android41x |
| 28 | + ) |
| 29 | + |
| 30 | + // Documentation |
| 31 | + const val dokkaCore: Lib = "org.jetbrains.dokka:dokka-gradle-plugin:0.9.18" |
| 32 | + const val dokkaAndroid: Lib = "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18" |
| 33 | + |
| 34 | + // Publishing |
| 35 | + const val androidMavenGradle: Lib = "com.github.dcendents:android-maven-gradle-plugin:2.1" |
| 36 | + const val androidMavenPublish: Lib = "digital.wup:android-maven-publish:3.6.2" |
| 37 | + const val bintray: Lib = "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4" |
| 38 | +} |
| 39 | + |
| 40 | +/** |
| 41 | + * Third-party dependencies used by the modules in this repository. |
| 42 | + */ |
| 43 | +object Libs { |
| 44 | + // Environment & Helpers |
| 45 | + const val kotlinStdLib: Lib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" |
| 46 | + const val kotlinReflect: Lib = "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" |
| 47 | + const val javaSemver: Lib = "com.github.zafarkhaja:java-semver:0.9.0" |
| 48 | + const val annimonStream: Lib = "com.annimon:stream:1.2.1" |
| 49 | + const val commonsIO: Lib = "commons-io:commons-io:2.6" |
| 50 | + const val commonsLang: Lib = "commons-lang:commons-lang:2.6" |
| 51 | + |
| 52 | + // JUnit 5 |
| 53 | + private const val junitJupiterVersion = "5.6.2" |
| 54 | + private const val junitPlatformVersion = "1.6.2" |
| 55 | + private const val junitVintageVersion = "5.6.2" |
| 56 | + const val junitJupiterApi: Lib = "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion" |
| 57 | + const val junitJupiterEngine: Lib = "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion" |
| 58 | + const val junitJupiterParams: Lib = "org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion" |
| 59 | + const val junitPlatformCommons: Lib = "org.junit.platform:junit-platform-commons:$junitPlatformVersion" |
| 60 | + const val junitPlatformEngine: Lib = "org.junit.platform:junit-platform-engine:$junitPlatformVersion" |
| 61 | + const val junitPlatformLauncher: Lib = "org.junit.platform:junit-platform-launcher:$junitPlatformVersion" |
| 62 | + const val junitPlatformRunner: Lib = "org.junit.platform:junit-platform-runner:$junitPlatformVersion" |
| 63 | + const val junitVintageEngine: Lib = "org.junit.vintage:junit-vintage-engine:$junitVintageVersion" |
| 64 | + |
| 65 | + // Assertions & Testing |
| 66 | + private const val truthVersion = "0.43" |
| 67 | + const val truth: Lib = "com.google.truth:truth:$truthVersion" |
| 68 | + const val truthJava8Extensions: Lib = "com.google.truth.extensions:truth-java8-extension:$truthVersion" |
| 69 | + const val truthAndroidExtensions: Lib = "androidx.test.ext:truth:1.1.0" |
| 70 | + |
| 71 | + const val mockitoCore: Lib = "org.mockito:mockito-core:2.19.0" |
| 72 | + const val mockitoKotlin: Lib = "com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0" |
| 73 | + |
| 74 | + const val espressoCore: Lib = "androidx.test.espresso:espresso-core:3.2.0" |
| 75 | + const val androidxTestCore: Lib = "androidx.test:core:1.2.0" |
| 76 | + const val androidxTestMonitor: Lib = "androidx.test:monitor:1.2.0" |
| 77 | + const val androidxTestRunner: Lib = "androidx.test:runner:1.2.0" |
| 78 | + |
| 79 | + private const val spekVersion = "1.2.1" |
| 80 | + const val spekApi: Lib = "org.jetbrains.spek:spek-api:$spekVersion" |
| 81 | + const val spekEngine: Lib = "org.jetbrains.spek:spek-junit-platform-engine:$spekVersion" |
| 82 | + |
| 83 | + const val junit4: Lib = "junit:junit:4.13" |
| 84 | +} |
| 85 | + |
| 86 | +/* Helpers & Extensions */ |
| 87 | + |
| 88 | +typealias Lib = String |
| 89 | +val Lib.version get() = substringAfterLast(":") |
| 90 | + |
| 91 | +typealias Agp = Lib |
| 92 | +val Agp.shortVersion: String get() { |
| 93 | + // Extract first two components of the Maven dependency's version string. |
| 94 | + val components = substringAfterLast(":").split('.') |
| 95 | + if (components.size < 2) { |
| 96 | + throw IllegalArgumentException("Cannot derive AGP configuration name from: $this") |
| 97 | + } |
| 98 | + |
| 99 | + return "${components[0]}${components[1]}" |
| 100 | +} |
| 101 | +val Agp.configurationName: String get() { |
| 102 | + // Derive the Gradle configuration name from that |
| 103 | + // (Example: version = "3.2.0" --> configurationName = "testAgp32x") |
| 104 | + return "testAgp${shortVersion}x" |
| 105 | +} |
0 commit comments