Skip to content

Commit

Permalink
centralize loading plugins in the classpath in the root build.gradle.…
Browse files Browse the repository at this point in the history
…kts.

This makes KotlinCompile visible from the root projet. Use that to make all KotlinCompile tasks depend on GenerateSwagger
  • Loading branch information
martinbonnin committed Feb 8, 2020
1 parent 353af93 commit b0e45e7
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 62 deletions.
9 changes: 8 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ val preMerge = tasks.register("preMerge") {
dependsOn(subprojects.filter { it.name != "samples" }.map { it.tasks.named("check") })
}

plugins {
id("com.android.library").version("3.5.3").apply(false)
id("com.yelp.codegen.plugin").version("1.3.0").apply(false)
id("io.gitlab.arturbosch.detekt").version("1.4.0").apply(false)
kotlin("android").version("1.3.61").apply(false)
}

subprojects {
afterEvaluate { // Remove when we have lazy configuration
tasks.all {
if (name == "assembleDebug") {
if (this is org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
// assembleDebug needs the generated files
dependsOn(tasks.named("generateSwagger"))
}
Expand Down
21 changes: 4 additions & 17 deletions samples/groovy-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
jcenter()
}

dependencies {
classpath "com.android.tools.build:gradle:3.5.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
classpath "com.yelp.codegen:plugin:1.3.0"
}
plugins {
id("com.android.library")
id("kotlin-android")
id("com.yelp.codegen.plugin")
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "com.yelp.codegen.plugin"

android {
compileSdkVersion = 28
defaultConfig {
Expand Down
26 changes: 6 additions & 20 deletions samples/junit-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
jcenter()
}

dependencies {
classpath "com.android.tools.build:gradle:3.5.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
classpath "com.yelp.codegen:plugin:1.3.0"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.4.0"
}
plugins {
id("com.android.library")
id("kotlin-android")
id("com.yelp.codegen.plugin")
id("io.gitlab.arturbosch.detekt")
id("kotlin-kapt")
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "com.yelp.codegen.plugin"
apply plugin: "io.gitlab.arturbosch.detekt"
apply plugin: "kotlin-kapt"

android {
compileSdkVersion = 28
defaultConfig {
Expand Down
8 changes: 4 additions & 4 deletions samples/kotlin-android-moshi-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id("com.android.library") version "3.5.3"
kotlin("android") version "1.3.61"
id("com.yelp.codegen.plugin") version "1.3.0"
kotlin("kapt") version "1.3.61"
id("com.android.library")
id("kotlin-android")
id("com.yelp.codegen.plugin")
id("kotlin-kapt")
}

android {
Expand Down
6 changes: 3 additions & 3 deletions samples/kotlin-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("com.android.library") version "3.5.3"
kotlin("android") version "1.3.61"
id("com.yelp.codegen.plugin") version "1.3.0"
id("com.android.library")
kotlin("android")
id("com.yelp.codegen.plugin")
}

android {
Expand Down
21 changes: 4 additions & 17 deletions samples/kotlin-coroutines/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
jcenter()
}

dependencies {
classpath "com.android.tools.build:gradle:3.5.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
classpath "com.yelp.codegen:plugin:1.3.0"
}
plugins {
id("com.android.library")
id("kotlin-android")
id("com.yelp.codegen.plugin")
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "com.yelp.codegen.plugin"

android {
compileSdkVersion = 28
defaultConfig {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pluginManagement {
jcenter()
google()
}

resolutionStrategy {
eachPlugin {
if ("com.android" in requested.id.id) {
Expand Down

0 comments on commit b0e45e7

Please sign in to comment.