-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild.gradle
More file actions
175 lines (137 loc) · 4.94 KB
/
build.gradle
File metadata and controls
175 lines (137 loc) · 4.94 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
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
// -*- coding: utf-8; mode: conf-javaprop -*-
// SPDX-FileCopyrightText: 2016 ale5000
// SPDX-License-Identifier: GPL-3.0-or-later
buildscript {
apply from: 'dependencies.gradle'
}
plugins {
id 'base'
//id 'com.github.hierynomus.license-report' version '0.15.0'
//id 'com.github.spotbugs' version '4.7.6'
}
develocity.buildScan {
termsOfUseUrl.set 'https://gradle.com/help/legal-terms-of-use'
termsOfUseAgree.set 'yes'
publishing.onlyIf { System.getenv('UPLOAD_BUILD_SCAN') != null }
}
/* ===FUNCTIONS=== */
private void initialize() {
Properties props = new Properties()
defaultTasks 'tasks'
project.buildDir = project.file("output")
project.file('zip-content/module.prop').withInputStream { props.load(it) }
description = String.valueOf(props.getProperty('description'))
version = String.valueOf(props.getProperty('version')).toLowerCase(Locale.ENGLISH).trim()
group = String.valueOf(props.getProperty('group'))
ext.ourArchivesBaseName = String.valueOf(props.getProperty('id')).trim()
//ext.isBeta = version.endsWith('-beta')
//ext.isAlpha = version.endsWith('-alpha')
//ext.isSnapshot = version.endsWith('-snapshot')
println name
println 'Version: ' + version
println 'OS: ' + System.properties['os.name']
if(JavaVersion.current() < JavaVersion.VERSION_17) {
throw new GradleException('Java 17 or later is required')
}
}
private String getOurArchivesBaseName()
{
String val = String.valueOf("${ext.ourArchivesBaseName}")
if(val.isEmpty() || val == 'null')
throw new InvalidUserDataException('String is empty.')
return "${val}"
}
private void configureSigning(def android, File keystorePropsFile)
{
if(!keystorePropsFile.exists()) return
if(android == null) throw new GradleException('android is null inside configureSigning()')
println 'Signed build'
Properties keystoreProps = new Properties()
keystoreProps.load(new FileInputStream(keystorePropsFile))
String keyStorePassword
boolean fallbackToEnv = keystoreProps.containsKey('fallbackToEnv') && keystoreProps['fallbackToEnv'] == 'true'
if(keystoreProps.containsKey('keyStorePassword'))
keyStorePassword = keystoreProps['keyStorePassword']
else if(fallbackToEnv)
keyStorePassword = System.getenv('KEYSTORE_PASSWORD')
if(keyStorePassword == null || keyStorePassword.isEmpty())
throw new InvalidUserDataException('Keystore password is empty')
android.signingConfigs {
config {
storeFile = rootProject.file(keystoreProps['storeFile'])
storePassword = keyStorePassword
keyAlias = keystoreProps['keyAlias']
keyPassword = keyStorePassword
}
}
android.buildTypes.release.signingConfig android.signingConfigs.config
}
initialize()
/* ===BLOCKS=== */
base {
archivesName = getOurArchivesBaseName()
}
/* ==TASKS=== */
tasks.register('cleanCache', Delete) {
delete "${projectDir}/cache"
}
tasks.register('cleanRecoveryOutput', Delete) {
delete "${projectDir}/recovery-simulator/output"
}
tasks.named('clean').configure {
finalizedBy tasks.named('cleanRecoveryOutput')
finalizedBy tasks.named('cleanCache')
}
static String getScriptExt() {
if(System.properties['os.name'].toLowerCase(Locale.ROOT).contains('windows')) {
return '.bat'
} else {
return '.sh'
}
}
tasks.register('buildOta', Exec) {
group = '- OTA build'
description = 'Build the flashable zip [Full edition].'
doFirst {
println 'Building the flashable zip with Gradle...'
environment BUILD_TYPE: 'full'
environment NO_PAUSE: '1'
executable "${projectDir}/build" + getScriptExt()
}
}
tasks.register('buildOtaOSS', Exec) {
group = '- OTA build'
description = 'Build the flashable zip [OSS edition].'
doFirst {
println 'Building the flashable zip (open-source components only) with Gradle...'
environment BUILD_TYPE: 'oss'
environment NO_PAUSE: '1'
executable "${projectDir}/build" + getScriptExt()
}
}
tasks.named('build').configure {
finalizedBy buildOtaOSS
}
tasks.register('installTest', Exec) {
group = 'verification'
description = 'Test the flashable zip in a simulated Android recovery environment on your PC.'
mustRunAfter build, buildOta, buildOtaOSS
doFirst {
environment LIVE_SETUP_ALLOWED: 'false' /* Live setup doesn't work when executed through Gradle */
environment NO_PAUSE: '1'
environment BB_GLOBBING: '1'
executable "${projectDir}/recovery-simulator/recovery" + getScriptExt()
args "${projectDir}/output/*.zip"
}
}
tasks.register('test') {
dependsOn installTest
}
// Dummy task
tasks.register('install')
tasks.named('wrapper').configure {
println 'Gradle: ' + gradleVersionTarget
gradleVersion = gradleVersionTarget
//distributionType = Wrapper.DistributionType.ALL
distributionSha256Sum = gradleSha256Sum
}