Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated build gradle to Kts #104

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
---

## master
* Converted `build.gradle`s to `build.gradle.kts`

## 2.0.0
* Upgrade kotlin to 1.5.31 in JsPlugin
Expand Down
16 changes: 7 additions & 9 deletions build.gradle → build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply from: 'jacoco.gradle'
apply(from= "jacoco.gradle")

buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath libs.kotlinx.atomicfu.gradle
classpath libs.jacoco.jacoco
classpath(libs.kotlinx.atomicfu.gradle)
classpath(libs.jacoco.jacoco)
}
}

allprojects {
group GROUP
version VERSION
group = findProperty("GROUP") as String
version = findProperty("VERSION") as String

repositories {
mavenCentral()
google()
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions{
allWarningsAsErrors = true
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.allWarningsAsErrors = true
}
}
18 changes: 11 additions & 7 deletions mockingbird/build.gradle → mockingbird/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import groovy.lang.Closure

apply from: '../utils.gradle'
plugins{
id("org.jetbrains.kotlin.multiplatform")
}

setupMultiplatformLibrary(project, true)
setupAllTargetsWithDefaultSourceSets(project, true)
apply(from = "../utils.gradle")
val setupMultiplatformLibrary: Closure<Any> by ext
setupMultiplatformLibrary(project, true, true)

kotlin {
explicitApi()
sourceSets {
commonMain {
val commonMain by getting {
dependencies {
implementation libs.kotlinx.atomicfu
implementation libs.touchlab.stately.isolate
implementation libs.kotlin.test
implementation(libs.kotlinx.atomicfu)
implementation(libs.touchlab.stately.isolate)
implementation(libs.kotlin.test)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import groovy.lang.Closure

apply from: '../../utils.gradle'

setupMultiplatformLibrary(project, false)
setupAllTargetsWithDefaultSourceSets(project, false) // FIXME Js excluded here
plugins{
id("org.jetbrains.kotlin.multiplatform")
}

apply(from = "../../utils.gradle")
val setupMultiplatformLibrary: Closure<Any> by ext
setupMultiplatformLibrary(project, false, false) // TODO extract JsPlugin from buildSrc to be used in other modules

kotlin {
sourceSets {
commonMain {
val commonMain by getting {
dependencies {
implementation libs.kotlinx.atomicfu
implementation(libs.kotlinx.atomicfu)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import groovy.lang.Closure

apply from: '../../../utils.gradle'
plugins{
id("org.jetbrains.kotlin.multiplatform")
}

setupMultiplatformLibrary(project, false)
setupAllTargetsWithDefaultSourceSets(project, false) // FIXME Js excluded here
apply(from = "../../../utils.gradle")
val setupMultiplatformLibrary: Closure<Any> by ext
setupMultiplatformLibrary(project, false, false) // TODO extract JsPlugin from buildSrc to be used in other modules

kotlin {
sourceSets {
commonMain {
val commonMain by getting {
dependencies {
implementation libs.kotlinx.atomicfu
implementation(libs.kotlinx.atomicfu)
}
}
}
}

}
51 changes: 0 additions & 51 deletions samples/sample/build.gradle

This file was deleted.

55 changes: 55 additions & 0 deletions samples/sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
*
* Copyright Careem, an Uber Technologies Inc. company
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import groovy.lang.Closure

plugins{
id("org.jetbrains.kotlin.multiplatform")
}

apply(from = "../../utils.gradle")
val setupMultiplatformLibrary: Closure<Any> by ext
setupMultiplatformLibrary(project, false, false) // TODO extract JsPlugin from buildSrc to be used in other modules

apply(plugin = "com.careem.mockingbird")

kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation(project(":common-sample"))
implementation(project(":common:sample"))
implementation("com.careem.mockingbird:mockingbird")
implementation(libs.touchlab.stately.isolate)
}
}
}
}

configure<com.careem.mockingbird.MockingbirdPluginExtension> {
generateMocksFor = listOf(
"com.careem.mockingbird.sample.JavaTypes",
"com.careem.mockingbird.sample.InterfaceWithGenerics",
"com.careem.mockingbird.sample.PippoSample",
"com.careem.mockingbird.sample.Mock1",
"com.careem.mockingbird.sample.MockWithExternalDependencies",
"com.careem.mockingbird.common.sample.ExternalContract",
"com.careem.mockingbird.sample.OuterInterface",
"com.careem.mockingbird.sample.MultipleGetterProperties",
"com.careem.mockingbird.common.sample.ExternalDep"
)
}

22 changes: 8 additions & 14 deletions utils.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* limitations under the License.
*/

void setupMultiplatformLibrary(Project project, Boolean shouldPublish = true) {
project.apply plugin: 'org.jetbrains.kotlin.multiplatform'
void setupMultiplatformLibrary(Project project, Boolean shouldPublish = true, Boolean includeJs = true) {
if (shouldPublish) {
project.apply from: '../publishing.gradle'
project.group = GROUP
Expand All @@ -33,12 +32,14 @@ void setupMultiplatformLibrary(Project project, Boolean shouldPublish = true) {
}
}
}

setupAllTargetsWithDefaultSourceSets(project, includeJs)
}

void setupAllTargetsWithDefaultSourceSets(Project project, Boolean includeJs = true) {
private void setupAllTargetsWithDefaultSourceSets(Project project, Boolean includeJs = true) {
setupIosTargets(project)
setupJvmTarget(project)
if(includeJs){
if (includeJs) {
setupJsTarget(project)
}

Expand All @@ -50,7 +51,7 @@ void setupAllTargetsWithDefaultSourceSets(Project project, Boolean includeJs = t
jvmMain.dependsOn jvmJsCommonMain
jvmTest.dependsOn jvmJsCommonTest

if(includeJs){
if (includeJs) {
jsMain.dependsOn jvmJsCommonMain
jsTest.dependsOn jvmJsCommonTest
}
Expand All @@ -76,15 +77,9 @@ private void setupIosTargets(Project project) {

private void setupJvmTarget(Project project) {
project.kotlin {
targets.fromPreset(presets.jvm, 'jvm')
jvm()

sourceSets {
jvmMain {
dependencies {

}
}

jvmTest {
dependencies {
implementation libs.junit.junit
Expand All @@ -98,6 +93,5 @@ private void setupJsTarget(Project project) {
project.apply plugin: JsPlugin
}

ext.setupMultiplatformLibrary = { Project project, Boolean shouldPublish -> setupMultiplatformLibrary(project, shouldPublish) }
ext.setupAllTargetsWithDefaultSourceSets = { Project project, Boolean includeJs -> setupAllTargetsWithDefaultSourceSets(project, includeJs) }
ext.setupMultiplatformLibrary = { Project project, Boolean shouldPublish, Boolean includeJs -> setupMultiplatformLibrary(project, shouldPublish, includeJs) }