-
Notifications
You must be signed in to change notification settings - Fork 44
/
build.gradle
121 lines (103 loc) · 3.74 KB
/
build.gradle
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
import com.android.build.gradle.LibraryPlugin
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
buildscript {
ext.compile_sdk = 35
ext.target_sdk = 35
ext.min_sdk = 26
ext.application_id = 'io.anytype.app'
ext.version_name = '1.0'
ext.version_code = 1
ext.test_runner = 'androidx.test.runner.AndroidJUnitRunner'
ext.onCi = project.properties.getOrDefault("com.anytype.ci", "false").toBoolean()
def githubProperties = new Properties()
def githubPropertiesFile = file("$rootDir${File.separator}github.properties")
githubProperties.load(new FileInputStream(githubPropertiesFile))
def apiKeysProperties = new Properties()
def apiKeysPropertiesFile = file("$rootDir${File.separator}apikeys.properties")
apiKeysProperties.load(new FileInputStream(apiKeysPropertiesFile))
ext.sentryApiKey = apiKeysProperties["sentry_dsn"]
repositories {
mavenLocal()
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
if (ext.onCi) {
dependencies {
classpath "com.github.openkin:license-gradle-plugin:0d9582e233"
}
}
}
plugins {
alias(libs.plugins.application) apply false
alias(libs.plugins.library) apply false
alias(libs.plugins.kotlinAndroid) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.kserialization) apply false
alias(libs.plugins.wire) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.firebaseDistribution) apply false
alias(libs.plugins.gms) apply false
alias(libs.plugins.ksp) apply false
}
def testDebugAll = tasks.create("testDebugAll")
//https://www.droidcon.com/2022/03/11/reducing-gradle-boilerplate-in-multi-module-android-projects/
subprojects {
project.plugins.whenPluginAdded { plugin ->
if (plugin instanceof LibraryPlugin) {
android {
def config = rootProject.extensions.getByName("ext")
compileSdkVersion config["compile_sdk"]
defaultConfig {
minSdkVersion config["min_sdk"]
targetSdkVersion config["target_sdk"]
testInstrumentationRunner config["test_runner"]
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
}
if (plugin instanceof KotlinAndroidPluginWrapper) {
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
}
}
}
plugins.withId("kotlin") {
testDebugAll.dependsOn(tasks.named("test"))
}
plugins.withId("com.android.library") {
project.apply from: "$rootDir/lint.gradle"
afterEvaluate {
testDebugAll.dependsOn(tasks.named("testDebugUnitTest"))
}
}
plugins.withId("com.android.application") {
project.apply from: "$rootDir/lint.gradle"
afterEvaluate {
testDebugAll.dependsOn(tasks.named("testDebugUnitTest"))
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
tasks.register("installGitHooks") {
setGroup("Build Setup")
setDescription("Install local repository git hooks")
exec {
commandLine 'sh', '-c', 'git config core.hooksPath .githooks'
}
}
var initialTaskNames = getProject().getGradle().getStartParameter().getTaskNames()
getProject().getGradle().getStartParameter().setTaskNames(
initialTaskNames + Collections.singletonList("installGitHooks"))