Skip to content

Commit

Permalink
Update buildSrc
Browse files Browse the repository at this point in the history
  • Loading branch information
wax911 committed Nov 22, 2021
1 parent f574344 commit ad7fd30
Show file tree
Hide file tree
Showing 13 changed files with 489 additions and 173 deletions.
13 changes: 9 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ repositories {
google()
jcenter()
mavenCentral()
gradlePluginPortal()
maven {
url = URI("https://www.jitpack.io")
setUrl("https://plugins.gradle.org/m2/")
}
}

val buildToolsVersion = "7.0.3"
val kotlinVersion = "1.4.31"
val dokkaVersion = "0.10.1"
val manesVersion = "0.33.0"
val kotlinVersion = "1.4.32"
val dokkaVersion = "1.4.32"
val manesVersion = "0.38.0"
val spotlessVersion = "6.0.0"

dependencies {
/* Depend on the android gradle plugin, since we want to access it in our plugin */
Expand All @@ -32,6 +34,9 @@ dependencies {
/** Dependency management */
implementation("com.github.ben-manes:gradle-versions-plugin:$manesVersion")

/** Spotless */
implementation("com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion")

/* Depend on the default Gradle API's since we want to build a custom plugin */
implementation(gradleApi())
implementation(localGroovy())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ object Libraries {
object AndroidX {

object Activity {
private const val version = "1.2.0-alpha06"
private const val version = "1.2.0"
const val activity = "androidx.activity:activity:$version"
const val activityKtx = "androidx.activity:activity-ktx:$version"
}

object Annotation {
private const val version = "1.2.0-alpha01"
private const val version = "1.2.0"
const val annotation = "androidx.annotation:annotation:$version"
}

Expand All @@ -40,24 +40,24 @@ object Libraries {
}

object Core {
private const val version = "1.5.0-alpha01"
private const val version = "1.5.0"
const val core = "androidx.core:core:$version"
const val coreKtx = "androidx.core:core-ktx:$version"
}

object ConstraintLayout {
private const val version = "2.0.0-beta7"
private const val version = "2.0.0"
const val constraintLayout = "androidx.constraintlayout:constraintlayout:$version"
const val constraintLayoutSolver = "androidx.constraintlayout:constraintlayout-solver:$version"
}

object Emoji {
private const val version = "1.1.0-rc01"
private const val version = "1.1.0"
const val appCompat = "androidx.emoji:emoji-appcompat:$version"
}

object Fragment {
private const val version = "1.3.0-alpha06"
private const val version = "1.3.0"
const val fragment = "androidx.fragment:fragment:$version"
const val fragmentKtx = "androidx.fragment:fragment-ktx:$version"
const val test = "androidx.fragment:fragment-ktx:fragment-testing$version"
Expand Down Expand Up @@ -86,7 +86,7 @@ object Libraries {
}

object Recycler {
private const val version = "1.2.0-alpha03"
private const val version = "1.2.0"
const val recyclerView = "androidx.recyclerview:recyclerview:$version"
const val recyclerViewSelection = "androidx.recyclerview:recyclerview-selection:$version"
}
Expand All @@ -100,36 +100,36 @@ object Libraries {
}

object StartUp {
private const val version = "1.0.0-alpha02"
private const val version = "1.1.0"
const val startUpRuntime = "androidx.startup:startup-runtime:$version"
}

object SwipeRefresh {
private const val version = "1.1.0-rc01"
private const val version = "1.1.0"
const val swipeRefreshLayout = "androidx.swiperefreshlayout:swiperefreshlayout:$version"
}

object Test {
private const val version = "1.3.0-rc01"
private const val version = "1.3.0"
const val core = "androidx.test:core:$version"
const val coreKtx = "androidx.test:core-ktx:$version"
const val runner = "androidx.test:runner:$version"
const val rules = "androidx.test:rules:$version"

object Espresso {
private const val version = "3.3.0-rc01"
private const val version = "3.3.0"
const val core = "androidx.test.espresso:espresso-core:$version"
}

object Extension {
private const val version = "1.1.2-rc01"
private const val version = "1.1.2"
const val junit = "androidx.test.ext:junit:$version"
const val junitKtx = "androidx.test.ext:junit-ktx:$version"
}
}

object Work {
private const val version = "2.4.0-beta01"
private const val version = "2.4.0"
const val runtimeKtx = "androidx.work:work-runtime-ktx:$version"
const val runtime = "androidx.work:work-runtime:$version"
const val test = "androidx.work:work-test:$version"
Expand Down Expand Up @@ -163,7 +163,7 @@ object Libraries {
}

object Coil {
private const val version = "0.11.0"
private const val version = "1.2.1"
const val coil = "io.coil-kt:coil:$version"
const val base = "io.coil-kt:coil-base:$version"
const val gif = "io.coil-kt:coil-gif:$version"
Expand All @@ -174,15 +174,15 @@ object Libraries {
object Google {

object Material {
private const val version = "1.3.0-alpha01"
private const val version = "1.3.0"
const val material = "com.google.android.material:material:$version"
}
}

object JetBrains {

object Dokka {
private const val version = "1.4.0"
private const val version = "1.4.32"
const val gradlePlugin = "org.jetbrains.dokka:dokka-gradle-plugin:$version"
}

Expand All @@ -203,7 +203,7 @@ object Libraries {

object KotlinX {
object Coroutines {
private const val version = "1.3.8"
private const val version = "1.4.3"
const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"
const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"
const val test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:$version"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,32 @@ package co.anitrend.retrofit.graphql.buildSrc.common

object Versions {

private fun Int.toVersion(): String {
return if (this < 9) "0$this" else "$this"
}

const val compileSdk = 30
const val targetSdk = 30
const val minSdk = 17

const val versionCode = 110012
const val versionName = "0.11.0-beta02"
private const val major = 0
private const val minor = 11
private const val patch = 0
private const val revision = 2

private const val channel = "beta"

const val versionCode = major * 100_000 + minor * 10_000 + patch * 1_000 + revision * 100
val versionName = if (revision > 0)
"$major.$minor.$patch-$channel${revision.toVersion()}"
else "$major.$minor.$patch"

const val mockk = "1.10.0"
const val junit = "4.13"
const val mockk = "1.12.0"
const val junit = "4.13.2"

const val timber = "4.7.1"
const val threeTenBp = "1.2.4"
const val timber = "5.0.1"
const val threeTenBp = "1.3.1"
const val ktlint = "0.43.0"

const val debugDB = "1.0.6"
const val treesSence = "0.3.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package co.anitrend.retrofit.graphql.buildSrc.module

internal object Modules {

interface Module {
val id: String

/**
* @return Formatted id of module as a path string
*/
fun path(): String = ":$id"
}

enum class Components(override val id: String) : Module {
App("app"),
Library("library")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import co.anitrend.retrofit.graphql.buildSrc.plugin.components.configureAndroid
import co.anitrend.retrofit.graphql.buildSrc.plugin.components.configureDependencies
import co.anitrend.retrofit.graphql.buildSrc.plugin.components.configureOptions
import co.anitrend.retrofit.graphql.buildSrc.plugin.components.configurePlugins
import co.anitrend.retrofit.graphql.buildSrc.plugin.components.configureSpotless
import org.gradle.api.Plugin
import org.gradle.api.Project

Expand Down Expand Up @@ -38,5 +39,6 @@ open class CorePlugin : Plugin<Project> {
project.configureAndroid()
project.configureOptions()
project.configureDependencies()
project.configureSpotless()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,36 @@ package co.anitrend.retrofit.graphql.buildSrc.plugin.components

import co.anitrend.retrofit.graphql.buildSrc.plugin.extensions.baseExtension
import co.anitrend.retrofit.graphql.buildSrc.common.Versions
import co.anitrend.retrofit.graphql.buildSrc.common.isLibraryModule
import co.anitrend.retrofit.graphql.buildSrc.common.isSampleModule
import co.anitrend.retrofit.graphql.buildSrc.plugin.extensions.isLibraryModule
import co.anitrend.retrofit.graphql.buildSrc.plugin.extensions.isSampleModule
import co.anitrend.retrofit.graphql.buildSrc.plugin.extensions.spotlessExtension
import co.anitrend.retrofit.graphql.buildSrc.plugin.extensions.baseAppExtension
import co.anitrend.retrofit.graphql.buildSrc.plugin.extensions.libraryExtension
import co.anitrend.retrofit.graphql.buildSrc.plugin.extensions.libraryExtension
import com.android.build.gradle.internal.dsl.DefaultConfig
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
import java.io.File

internal fun Project.configureSpotless(): Unit {
if (!isSampleModule())
spotlessExtension().run {
kotlin {
target("**/*.kt")
targetExclude("$buildDir/**/*.kt", "bin/**/*.kt", "**/test/**")
ktlint(Versions.ktlint).userData(
mapOf(
"android" to "true",
"max_line_length" to "120"
)
)
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
}
}

@Suppress("UnstableApiUsage")
private fun DefaultConfig.applyAdditionalConfiguration(project: Project) {
if (project.isSampleModule()) {
Expand All @@ -32,10 +51,10 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run {
compileSdkVersion(Versions.compileSdk)
defaultConfig {
if (isSampleModule())
minSdkVersion(21)
minSdk = 21
else
minSdkVersion(Versions.minSdk)
targetSdkVersion(Versions.targetSdk)
minSdk = Versions.minSdk
targetSdk = Versions.targetSdk
versionCode = Versions.versionCode
versionName = Versions.versionName
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -56,9 +75,9 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run {
}

packagingOptions {
exclude("META-INF/NOTICE.txt")
exclude("META-INF/LICENSE")
exclude("META-INF/LICENSE.txt")
excludes.add("META-INF/NOTICE.txt")
excludes.add("META-INF/LICENSE")
excludes.add("META-INF/LICENSE.txt")
}

sourceSets {
Expand Down Expand Up @@ -99,7 +118,6 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run {
freeCompilerArgs = if (isSampleModule()) listOf(
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xopt-in=kotlinx.coroutines.FlowPreview",
"-Xopt-in=kotlinx.coroutines.FlowPreview",
"-Xopt-in=kotlin.Experimental"
) else listOf("-Xopt-in=kotlin.Experimental")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package co.anitrend.retrofit.graphql.buildSrc.plugin.components

import co.anitrend.retrofit.graphql.buildSrc.plugin.strategy.DependencyStrategy
import co.anitrend.retrofit.graphql.buildSrc.plugin.extensions.implementation
import org.gradle.api.Project

internal fun Project.configureDependencies() {
val dependencyStrategy = DependencyStrategy(project.name)
dependencies.add("implementation",
val dependencyStrategy = DependencyStrategy(project)
dependencies.implementation(
fileTree("libs") {
include("*.jar")
}
Expand Down

0 comments on commit ad7fd30

Please sign in to comment.