Skip to content

Commit

Permalink
Decoupling plugin from buildScript
Browse files Browse the repository at this point in the history
* Moved the plugin on its standalone module to be able to publish
* Refactor and clean up
* Gradle wrapper upgrade
  • Loading branch information
MarcoSignoretto committed Aug 19, 2021
1 parent 618a6dc commit 9c4cff5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 59 deletions.
26 changes: 22 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,30 @@ apply from: 'jacoco.gradle'

buildscript {
repositories {
mavenLocal()
google()
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://plugins.gradle.org/m2/" }

maven {
url 'https://artifactory-pro.careem-internal.com/artifactory/mobile-libs-release'
credentials {
username project.hasProperty('careem_artifactory_username') ?
careem_artifactory_username : System.env.careem_artifactory_username
password project.hasProperty('careem_artifactory_api_key') ?
careem_artifactory_api_key : System.env.careem_artifactory_api_key
}
content {
includeGroup "com.careem.mockingbird"
}
mavenContent {
releasesOnly()
}
}
}
dependencies {
classpath "com.careem.mockingbird:mockingbird-compiler:1.11.0-SNAPSHOT" // FIXME I want to depend on the module directly not on published version
classpath libs.kotlinx.atomicfu.gradle
classpath libs.jacoco.jacoco
}
Expand All @@ -39,10 +57,10 @@ allprojects {
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://plugins.gradle.org/m2/" }
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions.allWarningsAsErrors = true
}
// FIXME I want warnings as errors but I'm getting gradle and kotlin classpatch conflict error
// tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
// kotlinOptions.allWarningsAsErrors = true
// }
}

void setupMultiplatformLibrary(Project project, Boolean shouldPublish = true) {
Expand Down
19 changes: 0 additions & 19 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,10 @@ repositories {
mavenCentral()
google()
gradlePluginPortal()
maven {
url = uri(project.properties["careem_artifactory_url"] as String? ?: System.getenv("careem_artifactory_url"))
credentials {
username = project.properties["careem_artifactory_username"] as String? ?: System.getenv("careem_artifactory_username")
password = project.properties["careem_artifactory_api_key"] as String? ?: System.getenv("careem_artifactory_api_key")
}
content {
includeGroup("com.careem.mockingbird")
}
mavenContent {
releasesOnly()
}
}
}

dependencies {
implementation(libs.kotlin.gradle)
implementation(libs.kotlin.reflectjvm)
implementation(libs.square.kotlinpoet)
implementation(libs.square.kotlinpoet.metadata)
implementation(libs.square.kotlinpoet.metadata.specs)
implementation(libs.kotlinx.metadatajvm)
implementation(libs.careem.mockingbird) // FIXME avoid this dep but use project dep instead
}

kotlin {
Expand Down
30 changes: 4 additions & 26 deletions mockingbird-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ plugins {
`kotlin-dsl`
}

apply(from = "../publishing.gradle")

gradlePlugin {
plugins {
register("mockingbird") {
Expand All @@ -35,38 +37,14 @@ repositories {
gradlePluginPortal()
}

kotlin {
// Add Deps to compilation, so it will become available in main project
sourceSets.getByName("main").kotlin.srcDirs("buildSrc/src/main/kotlin")
println("ROOT:${rootProject.allprojects}")
}

dependencies {
implementation(libs.kotlin.gradle)
implementation(libs.kotlin.reflectjvm)
implementation(libs.square.kotlinpoet)
implementation(libs.square.kotlinpoet.metadata)
implementation(libs.square.kotlinpoet.metadata.specs)
implementation(libs.kotlinx.metadatajvm)
implementation(project(":mockingbird"))
}

//task pluginVersion {
// def outputDir = file("gen")
//
// inputs.property 'version', version
// outputs.dir outputDir
//
// doLast {
// def versionFile = file("$outputDir/com/squareup/sqldelight/Version.kt")
// versionFile.parentFile.mkdirs()
// versionFile.text = """// Generated file. Do not edit!
//package com.squareup.sqldelight
//
//val VERSION = "${project.version}"
//"""
// }
//}
//
//tasks.getByName('compileKotlin').dependsOn('pluginVersion')
//
//apply from: "$rootDir/gradle/gradle-mvn-push.gradle"

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.careem.mockingbird

import com.squareup.kotlinpoet.FileSpec
import com.squareup.kotlinpoet.FunSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.ListProperty
import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.listProperty
import org.gradle.kotlin.dsl.property
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.setValue
import kotlin.reflect.KProperty

/*
* Copyright Careem, an Uber Technologies Inc. company
*
Expand All @@ -22,6 +13,16 @@ import kotlin.reflect.KProperty
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.careem.mockingbird

import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.ListProperty
import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.listProperty
import org.gradle.kotlin.dsl.property
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.setValue
import kotlin.reflect.KProperty

interface MockingbirdPluginExtension {
var generateMocksFor: List<String>
Expand Down
2 changes: 1 addition & 1 deletion samples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setupMultiplatformLibrary(project)
setupAllTargetsWithDefaultSourceSets(project)
apply plugin: MockingbirdPlugin
apply plugin: "com.careem.mockingbird"

kotlin {
sourceSets {
Expand Down

0 comments on commit 9c4cff5

Please sign in to comment.