-
Notifications
You must be signed in to change notification settings - Fork 38
/
BugsnagPluginExtension.kt
128 lines (94 loc) · 4.19 KB
/
BugsnagPluginExtension.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.bugsnag.android.gradle
import com.bugsnag.android.gradle.internal.listProperty
import com.bugsnag.android.gradle.internal.mapProperty
import com.bugsnag.android.gradle.internal.newInstance
import com.bugsnag.android.gradle.internal.property
import groovy.lang.Closure
import org.gradle.api.Action
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.util.ConfigureUtil
import java.io.File
import java.util.Locale
import javax.inject.Inject
// To make kotlin happy with gradle's nullability
private val NULL_STRING: String? = null
private val NULL_BOOLEAN: Boolean? = null
private val NULL_FILE: File? = null
private val NULL_INT: Int? = null
internal const val UPLOAD_ENDPOINT_DEFAULT: String = "https://upload.bugsnag.com"
/**
* Defines configuration options (Gradle plugin extensions) for the BugsnagPlugin
*/
open class BugsnagPluginExtension @Inject constructor(objects: ObjectFactory) {
val sourceControl: SourceControl = objects.newInstance()
val enabled: Property<Boolean> = objects.property<Boolean>()
.convention(true)
val uploadJvmMappings: Property<Boolean> = objects.property<Boolean>()
.convention(true)
val uploadNdkMappings: Property<Boolean> = objects.property<Boolean>()
.convention(NULL_BOOLEAN)
val uploadNdkUnityLibraryMappings: Property<Boolean> = objects.property<Boolean>()
.convention(NULL_BOOLEAN)
val uploadReactNativeMappings: Property<Boolean> = objects.property<Boolean>()
.convention(NULL_BOOLEAN)
val reportBuilds: Property<Boolean> = objects.property<Boolean>()
.convention(true)
val uploadDebugBuildMappings: Property<Boolean> = objects.property<Boolean>()
.convention(false)
val endpoint: Property<String> = objects.property<String>()
.convention(UPLOAD_ENDPOINT_DEFAULT)
val releasesEndpoint = objects.property<String>()
.convention("https://build.bugsnag.com")
val overwrite: Property<Boolean> = objects.property<Boolean>()
.convention(false)
val retryCount: Property<Int> = objects.property<Int>()
.convention(0)
val sharedObjectPaths: ListProperty<File> = objects.listProperty<File>()
.convention(emptyList())
val dexguardMajorVersion: Property<Int> = objects.property<Int>()
.convention(NULL_INT)
val nodeModulesDir: Property<File> = objects.property<File>()
.convention(NULL_FILE)
val projectRoot: Property<String> = objects.property<String>().convention(NULL_STRING)
val failOnUploadError: Property<Boolean> = objects.property<Boolean>()
.convention(true)
val requestTimeoutMs: Property<Long> = objects.property<Long>()
.convention(60000)
// release API values
val builderName: Property<String> = objects.property<String>().convention(NULL_STRING)
val metadata: MapProperty<String, String> = objects.mapProperty<String, String>()
.convention(emptyMap())
val objdumpPaths: MapProperty<String, String> = objects.mapProperty<String, String>()
.convention(emptyMap())
val useLegacyNdkSymbolUpload: Property<Boolean> = objects.property<Boolean>()
.convention(NULL_BOOLEAN)
// exposes sourceControl as a nested object on the extension,
// see https://docs.gradle.org/current/userguide/custom_gradle_types.html#nested_objects
fun sourceControl(closure: Closure<SourceControl>) {
ConfigureUtil.configure(closure, sourceControl)
}
fun sourceControl(action: Action<SourceControl>) {
action.execute(sourceControl)
}
internal var filter: Action<VariantFilter> = Action {
if (it.name.toLowerCase(Locale.ENGLISH).contains("debug")) {
it.setEnabled(false)
}
}
fun variantFilter(action: Action<VariantFilter>) {
this.filter = action
}
}
interface VariantFilter {
val name: String
fun setEnabled(enabled: Boolean)
}
internal class VariantFilterImpl(override val name: String) : VariantFilter {
internal var variantEnabled: Boolean? = true
override fun setEnabled(enabled: Boolean) {
this.variantEnabled = enabled
}
}