Skip to content

Commit

Permalink
Merge pull request #105 from martinbonnin/remove-make
Browse files Browse the repository at this point in the history
Migrate Makefile targets to Gradle tasks
  • Loading branch information
cortinico authored Feb 10, 2020
2 parents cc71ca0 + 1102c57 commit 444b8c5
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cache:
- ${HOME}/.m2

script:
- make test
- ./gradlew preMerge

after_success:
- bash <(curl -s https://codecov.io/bash)
20 changes: 0 additions & 20 deletions Makefile

This file was deleted.

64 changes: 64 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,67 @@ subprojects {
jcenter()
}
}

val installVenv = tasks.register("installVenv", Exec::class.java) {
description = "Install a new virtualenv in ./venv"

outputs.dir("./venv")

commandLine("virtualenv", "venv")
}

val installPreCommit = tasks.register("installPreCommit", Exec::class.java) {
description = "Installs pre-commit in ./venv"

dependsOn(installVenv)

outputs.file("./venv/bin/pre-commit")

commandLine("./venv/bin/pip", "install", "pre-commit")
}

val installHooks = tasks.register("installHooks", Exec::class.java) {
description = "Run pre-commit hooks without installing them"

dependsOn(installPreCommit)

outputs.file(".git/hooks/pre-commit")
inputs.file(".pre-commit-config.yaml")

commandLine("./venv/bin/pre-commit", "install", "--install-hooks")
}

val runHooks = tasks.register("runHooks", Exec::class.java) {
description = "Run pre-commit hooks"

dependsOn(installPreCommit)

commandLine("./venv/bin/pre-commit", "run", "--all-files")
}

val preMerge = tasks.register("preMerge") {
description = "Runs pre-commit hooks, build the plugin and sample and execute tests."

dependsOn(runHooks)
dependsOn(gradle.includedBuild("gradle-plugin").task(":plugin:build"))
dependsOn(gradle.includedBuild("gradle-plugin").task(":plugin:check"))
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 (this is org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
// we need the generated files before we run the kotlin compile task
dependsOn(tasks.named("generateSwagger"))
}
}
}
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The check task requires a lot of MetaSpace. Not sure if it is a leak or something else
# But it is needed to make the tasks pass
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=2g
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 444b8c5

Please sign in to comment.