Skip to content

Commit

Permalink
chore: set library by plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercy811 committed Mar 1, 2024
1 parent b00660d commit d3fb6ca
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ rootProject.allprojects {
}
}

ext {
PUBLISH_VERSION = '4.0.0-beta.0'
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
buildFeatures.buildConfig true

compileSdkVersion 34
// Condition for namespace compatibility in AGP 8
if (project.android.hasProperty("namespace")) {
Expand All @@ -36,6 +42,9 @@ android {
}
defaultConfig {
minSdkVersion 16

buildConfigField 'String', 'SDK_VERSION', "\"${PUBLISH_VERSION}\""

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class AmplitudeFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
"init" -> {
val configuration = getConfiguration(call)
amplitude = Amplitude(configuration)

// Set library
amplitude.add(FlutterLibraryPlugin())

call.argument<String>("logLevel")?.let {
amplitude.logger.logMode = Logger.LogMode.valueOf(it.uppercase())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.amplitude.amplitude_flutter

import com.amplitude.core.Amplitude
import com.amplitude.core.events.BaseEvent
import com.amplitude.core.platform.Plugin
import com.amplitude.amplitude_flutter.BuildConfig

class FlutterLibraryPlugin: Plugin {
override val type: Plugin.Type = Plugin.Type.Before
override lateinit var amplitude: Amplitude

companion object {
const val SDK_LIBRARY = "amplitude-flutter"
const val SDK_VERSION = BuildConfig.SDK_VERSION
}

override fun execute(event: BaseEvent): BaseEvent? {
event.library = "$SDK_LIBRARY/$SDK_VERSION"
return super.execute(event)
}
}
14 changes: 14 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ module.exports = {
],
"countMatches": true
},
{
"files": ["android/build.gradle"],
"from": "PUBLISH_VERSION = \'.*\'",
"to": "PUBLISH_VERSION = \'${nextRelease.version}\'",
"results": [
{
"file": "android/build.gradle",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
},
]
}
],
Expand Down

0 comments on commit d3fb6ca

Please sign in to comment.