-
-
Notifications
You must be signed in to change notification settings - Fork 650
Expand file tree
/
Copy pathbuild.gradle
More file actions
130 lines (115 loc) · 5.1 KB
/
Copy pathbuild.gradle
File metadata and controls
130 lines (115 loc) · 5.1 KB
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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.application) apply false
// Not applied anywhere (built-in Kotlin is used instead) - declaring it here
// is what pins the Kotlin compiler version that AGP's built-in Kotlin uses.
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.maven.publish) apply false
alias(libs.plugins.dokka) apply false
}
allprojects {
repositories {
google()
mavenCentral()
maven { url = "https://central.sonatype.com/repository/maven-snapshots/" }
}
}
subprojects {
// Configured immediately (not deferred to afterEvaluate) so AGP 9's variant/component
// computation - which the maven-publish plugin depends on - sees the final config in time.
['com.android.library', 'com.android.application'].each { pluginId ->
plugins.withId(pluginId) {
android {
compileSdkVersion 37
defaultConfig {
minSdkVersion 23
targetSdkVersion 37
versionCode 1
versionName "$VERSION_NAME"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
buildFeatures {
buildConfig = true
}
// Built-in Kotlin (AGP 9+) replaces the old 'kotlinOptions' DSL.
kotlin {
compilerOptions {
// Support @JvmDefault (old '-Xjvm-default=all' is now '-jvm-default=no-compatibility')
freeCompilerArgs = ['-jvm-default=no-compatibility', '-opt-in=kotlin.RequiresOptIn']
}
}
}
dependencies {
implementation libs.kotlin.stdlib.jdk8
}
}
}
}
tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}
// ---------------------------------------------------------------------------
// hiddenjar — Gradle wrapper around cli/hiddenjar
//
// Build a custom android.jar (with hidden/internal APIs) from a running
// emulator or device. See docs/BUILD_CUSTOM_ANDROID_JAR_FROM_EMULATOR.md.
//
// ./gradlew buildHiddenJar -Papi=37
// ./gradlew buildHiddenJar -Papi=37 -Pinstall
// ./gradlew buildHiddenJar -PonlyFramework -Pserial=emulator-5554 -Poutput=/tmp/android-37.jar
// ./gradlew buildHiddenJar -Pavd=Pixel_10_API_37 -Pinstall
// ./gradlew hiddenJarDoctor
// ./gradlew restoreHiddenJar -Papi=37
//
// Value props: -Papi -Pserial -Pavd -Poutput -PsdkDir -PdexTools
// Flag props: -PonlyFramework -Pinstall -Pkeep -PkeepBodies
// Cross-platform: on Windows it runs the native PowerShell port (cli/hiddenjar.ps1),
// on macOS/Linux the bash script (cli/hiddenjar). No Git Bash needed on Windows.
// ---------------------------------------------------------------------------
ext.hiddenJarBashScript = "${rootDir}/cli/hiddenjar"
ext.hiddenJarPsScript = "${rootDir}/cli/hiddenjar.ps1"
// Windows has no bash → invoke the native PowerShell port; bash everywhere else.
ext.hiddenJarInvoke = { String sub, List extra ->
def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')
if (isWindows) {
return ['powershell', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', hiddenJarPsScript, sub] + extra
}
return ['bash', hiddenJarBashScript, sub] + extra
}
ext.hiddenJarArgs = { ->
def valueFlags = [api: '--api', serial: '--serial', avd: '--avd',
output: '--output', sdkDir: '--sdk-dir', dexTools: '--dex-tools']
def boolFlags = [onlyFramework: '--only-framework', install: '--install', keep: '--keep', keepBodies: '--keep-bodies']
def args = []
valueFlags.each { prop, flag ->
if (project.hasProperty(prop)) args += [flag, project.property(prop).toString()]
}
boolFlags.each { prop, flag ->
if (project.hasProperty(prop)) args += [flag]
}
return args
}
tasks.register('buildHiddenJar', Exec) {
group = 'hiddenjar'
description = 'Build a custom android.jar with hidden APIs from an emulator/device (use -Papi=N).'
commandLine = hiddenJarInvoke('build', hiddenJarArgs())
}
tasks.register('hiddenJarDoctor', Exec) {
group = 'hiddenjar'
description = 'Check hiddenjar prerequisites (adb, JDK, dex-tools).'
commandLine = hiddenJarInvoke('doctor', [])
}
tasks.register('restoreHiddenJar', Exec) {
group = 'hiddenjar'
description = 'Restore the original SDK android.jar from its backup (use -Papi=N).'
def args = []
if (project.hasProperty('api')) args += ['--api', project.property('api').toString()]
if (project.hasProperty('sdkDir')) args += ['--sdk-dir', project.property('sdkDir').toString()]
commandLine = hiddenJarInvoke('restore', args)
}