Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.navigation.ui.setupActionBarWithNavController
import android.view.Menu
import android.view.MenuItem
import com.grab.android.sample.databinding.ActivityMainBinding
import com.grab.sample.dummy.KMPDummyClass1
import com.grab.sample.dummy.KDummyClass1

class MainActivity : AppCompatActivity() {
Expand All @@ -35,6 +36,7 @@ class MainActivity : AppCompatActivity() {
}

KDummyClass1().method1()
KMPDummyClass1().method1()
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
Expand Down
16 changes: 9 additions & 7 deletions sample/build-logic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,26 @@ dependencies {
compileOnly libs.android.gradle.plugin
}


gradlePlugin {
plugins {
androidAppConfigPlugin {
id = 'com.sample.android.application'
implementationClass = 'com.grab.sample.buildplugin.AndroidAppConfigPlugin'
implementationClass = 'com.grab.sample.android.AndroidAppConfigPlugin'
}
androidLibConfigPlugin {
id = 'com.sample.android.library'
implementationClass = 'com.grab.sample.buildplugin.AndroidLibraryConfigPlugin'
implementationClass = 'com.grab.sample.android.AndroidLibraryConfigPlugin'
}

kotlinKmpConfigPlugin {
id = 'com.sample.kotlin.kmp'
implementationClass = 'com.grab.sample.jvm.KmpConfigPlugin'
}

kotlinLibConfigPlugin {
id = 'com.sample.kotlin.library'
implementationClass = 'com.grab.sample.buildplugin.KotlinLibraryConfigPlugin'
}
kotlinMultiplatformLibConfigPlugin {
id = 'com.sample.kotlin.multiplatform.library'
implementationClass = 'com.grab.sample.buildplugin.KotlinMultiplatformLibraryConfigPlugin'
implementationClass = 'com.grab.sample.jvm.KotlinLibraryConfigPlugin'
}
}
}
40 changes: 40 additions & 0 deletions sample/build-logic/src/main/java/com/grab/sample/Constants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* MIT License
*
* Copyright (c) 2024. Grabtaxi Holdings Pte Ltd (GRAB), All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE
*/

package com.grab.sample

import org.gradle.api.JavaVersion

object BuildConfig {
const val COMPILE_SDK = 34
const val JVM_TARGET = "17"
val JAVA_VERSION = JavaVersion.VERSION_17
const val MIN_SDK = 21
const val TARGET_SDK = 33
const val APPLICATION_ID = "com.grab.android.sample"
const val TEST_INSTRUMENTATION_RUNNER = "androidx.test.runner.AndroidJUnitRunner"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* MIT License
*
* Copyright (c) 2024. Grabtaxi Holdings Pte Ltd (GRAB), All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE
*/

package com.grab.sample.android

import com.android.build.api.dsl.ApplicationExtension
import com.grab.sample.BuildConfig
import com.grab.sample.gradle.ConfigurablePlugin
import com.grab.sample.jvm.kotlinCommon
import org.gradle.kotlin.dsl.configure

class AndroidAppConfigPlugin : ConfigurablePlugin({
plugins.apply("com.android.application")
plugins.apply("org.jetbrains.kotlin.android")

extensions.configure<ApplicationExtension> {
compileSdk = BuildConfig.COMPILE_SDK

defaultConfig {
applicationId = BuildConfig.APPLICATION_ID
minSdk = BuildConfig.MIN_SDK
targetSdk = BuildConfig.TARGET_SDK
}

compileOptions {
sourceCompatibility = BuildConfig.JAVA_VERSION
targetCompatibility = BuildConfig.JAVA_VERSION
}
}

kotlinCommon()
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* MIT License
*
* Copyright (c) 2024. Grabtaxi Holdings Pte Ltd (GRAB), All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE
*/
package com.grab.sample.android


import com.android.build.gradle.LibraryExtension
import com.grab.sample.BuildConfig
import com.grab.sample.gradle.ConfigurablePlugin
import com.grab.sample.jvm.kotlinCommon
import org.gradle.kotlin.dsl.configure

class AndroidLibraryConfigPlugin : ConfigurablePlugin({
plugins.apply("com.android.library")
plugins.apply("kotlin-android")

extensions.configure<LibraryExtension> {
compileSdk = BuildConfig.COMPILE_SDK

defaultConfig {
minSdk = BuildConfig.MIN_SDK
testInstrumentationRunner = BuildConfig.TEST_INSTRUMENTATION_RUNNER
consumerProguardFiles("consumer-rules.pro")
}

compileOptions {
sourceCompatibility = BuildConfig.JAVA_VERSION
targetCompatibility = BuildConfig.JAVA_VERSION
}
}

kotlinCommon()
})

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.grab.sample.gradle

import org.gradle.api.Plugin
import org.gradle.api.Project

open class ConfigurablePlugin(
private val configuration: Project.() -> Unit
) : Plugin<Project> {
override fun apply(project: Project): Unit = configuration(project)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.grab.sample.jvm

import com.grab.sample.BuildConfig
import com.grab.sample.gradle.ConfigurablePlugin
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

class KmpConfigPlugin : ConfigurablePlugin({
plugins.apply("org.jetbrains.kotlin.multiplatform")

extensions.configure<KotlinMultiplatformExtension> {
jvm()
}

kotlinCommon()
})
Loading