-
Notifications
You must be signed in to change notification settings - Fork 60
/
build.gradle.kts
224 lines (195 loc) · 7.6 KB
/
build.gradle.kts
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/
@file:Suppress("StringLiteralDuplication")
import com.android.build.gradle.LibraryExtension
import com.datadog.gradle.config.AndroidConfig
import com.datadog.gradle.config.registerSubModuleAggregationTask
import org.gradle.api.internal.file.UnionFileTree
import org.gradle.api.internal.tasks.DefaultTaskDependencyFactory
import java.util.Properties
plugins {
`maven-publish`
alias(libs.plugins.nexusPublishGradlePlugin)
}
version = AndroidConfig.VERSION.name
buildscript {
repositories {
google()
mavenCentral()
maven { setUrl(com.datadog.gradle.Dependencies.Repositories.Gradle) }
}
dependencies {
classpath(libs.androidToolsGradlePlugin)
classpath(libs.kotlinGradlePlugin)
classpath(libs.kotlinSPGradlePlugin)
classpath(libs.dokkaGradlePlugin)
classpath(libs.unmockGradlePlugin)
classpath(libs.realmGradlePlugin)
classpath(libs.sqlDelightGradlePlugin)
classpath(libs.binaryCompatibilityGradlePlugin)
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { setUrl(com.datadog.gradle.Dependencies.Repositories.Jitpack) }
}
}
nexusPublishing {
this.repositories {
sonatype {
val sonatypeUsername = System.getenv("OSSRH_USERNAME")
val sonatypePassword = System.getenv("OSSRH_PASSWORD")
stagingProfileId.set("378eecbbe2cf9")
if (sonatypeUsername != null) username.set(sonatypeUsername)
if (sonatypePassword != null) password.set(sonatypePassword)
}
}
}
task<Delete>("clean") {
delete(rootProject.buildDir)
}
tasks.register("checkAll") {
dependsOn(
"lintCheckAll",
"unitTestAll",
"instrumentTestAll"
)
}
registerSubModuleAggregationTask("assembleLibraries", "assemble")
registerSubModuleAggregationTask("assembleLibrariesDebug", "assembleDebug")
registerSubModuleAggregationTask("assembleLibrariesRelease", "assembleRelease")
registerSubModuleAggregationTask("unitTestRelease", "testReleaseUnitTest")
registerSubModuleAggregationTask(
"unitTestReleaseFeatures",
"testReleaseUnitTest",
":features:"
)
registerSubModuleAggregationTask("unitTestReleaseIntegrations", "testReleaseUnitTest", ":integrations:")
registerSubModuleAggregationTask("unitTestDebug", "testDebugUnitTest")
registerSubModuleAggregationTask(
"unitTestDebugFeatures",
"testDebugUnitTest",
":features:"
)
registerSubModuleAggregationTask("unitTestDebugIntegrations", "testDebugUnitTest", ":integrations:")
tasks.register("assembleSampleRelease") {
dependsOn(
":sample:kotlin:assembleUs1Release",
":sample:wear:assembleUs1Release",
":sample:vendor-lib:assembleRelease"
)
}
tasks.register("unitTestTools") {
dependsOn(
":tools:unit:testJvmReleaseUnitTest",
":tools:detekt:test",
":tools:lint:test",
":tools:noopfactory:test"
)
}
tasks.register("unitTestAll") {
dependsOn(
":unitTestDebug",
":unitTestRelease",
":unitTestTools"
)
}
registerSubModuleAggregationTask("lintCheckAll", "lintRelease") {
dependsOn(":tools:lint:lint")
}
registerSubModuleAggregationTask("checkDependencyLicencesAll", "checkDependencyLicenses")
registerSubModuleAggregationTask("checkApiSurfaceChangesAll", "checkApiSurfaceChanges")
registerSubModuleAggregationTask("checkTransitiveDependenciesListAll", "checkTransitiveDependenciesList")
/**
* Task necessary to be compliant with the shared Android static analysis pipeline
*/
tasks.register("checkGeneratedFiles") {
dependsOn("checkDependencyLicencesAll")
dependsOn("checkApiSurfaceChangesAll")
dependsOn("checkTransitiveDependenciesListAll")
}
registerSubModuleAggregationTask("koverReportAll", "koverXmlReportRelease")
registerSubModuleAggregationTask("koverReportFeatures", "koverXmlReportRelease", ":features:")
registerSubModuleAggregationTask("koverReportIntegrations", "koverXmlReportRelease", ":integrations:")
registerSubModuleAggregationTask("printDetektClasspathAll", "printDetektClasspath")
registerSubModuleAggregationTask("printDetektClasspathFeatures", "printDetektClasspath", ":features:")
registerSubModuleAggregationTask("printDetektClasspathIntegrations", "printDetektClasspath", ":integrations:")
tasks.register("instrumentTestAll") {
dependsOn(":instrumented:integration:connectedCheck")
}
tasks.register("buildIntegrationTestsArtifacts") {
dependsOn(":instrumented:integration:assembleDebugAndroidTest")
dependsOn(":instrumented:integration:assembleDebug")
}
tasks.register("buildNdkIntegrationTestsArtifacts") {
dependsOn(":features:dd-sdk-android-ndk:assembleDebugAndroidTest")
// we need this artifact to trick Bitrise
dependsOn(":instrumented:integration:assembleDebug")
}
tasks.register("printSdkDebugRuntimeClasspath") {
val fileTreeClassPathCollector = UnionFileTree(
DefaultTaskDependencyFactory.withNoAssociatedProject()
)
val nonFileTreeClassPathCollector = mutableListOf<FileCollection>()
allprojects.minus(project).forEach { subproject ->
val childTask = subproject.tasks.register("printDebugRuntimeClasspath") {
doLast {
val ext =
subproject.extensions.findByType(LibraryExtension::class.java) ?: return@doLast
val classpath = ext.libraryVariants
.filter { it.name == "jvmDebug" || it.name == "debug" }
.map { libVariant ->
// returns also test part of classpath for now, no idea how to filter it out
libVariant.getCompileClasspath(null).filter { it.exists() }
}
.first()
if (classpath is FileTree) {
fileTreeClassPathCollector.addToUnion(classpath)
} else {
nonFileTreeClassPathCollector += classpath
}
}
}
[email protected](childTask)
}
doLast {
val fileCollections = mutableListOf<FileCollection>()
fileCollections.addAll(nonFileTreeClassPathCollector)
if (!fileTreeClassPathCollector.isEmpty) {
fileCollections.add(fileTreeClassPathCollector)
}
val result = fileCollections.flatMap {
it.files
}.toMutableSet()
val localPropertiesFile = File(project.rootDir, "local.properties")
if (localPropertiesFile.exists()) {
val localProperties = Properties().apply {
localPropertiesFile.inputStream().use { load(it) }
}
val sdkDirPath = localProperties["sdk.dir"]
val androidJarFilePath = listOf(
sdkDirPath,
"platforms",
"android-${AndroidConfig.TARGET_SDK}",
"android.jar"
)
result += File(androidJarFilePath.joinToString(File.separator))
}
val envSdkHome = System.getenv("ANDROID_SDK_ROOT")
if (!envSdkHome.isNullOrBlank()) {
val androidJarFilePath = listOf(
envSdkHome,
"platforms",
"android-${AndroidConfig.TARGET_SDK}",
"android.jar"
)
result += File(androidJarFilePath.joinToString(File.separator))
}
File("sdk_classpath").writeText(result.joinToString(File.pathSeparator) { it.absolutePath })
}
}