-
Notifications
You must be signed in to change notification settings - Fork 51
/
build.gradle
174 lines (153 loc) · 5.33 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
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
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
apply plugin: 'com.android.application'
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
}
android {
compileSdkVersion 30
buildToolsVersion '30.0.2'
ndkVersion '21.4.7075529'
defaultConfig {
versionCode 1043
versionName '3.1.4'
minSdkVersion 16
targetSdkVersion 30
renderscriptTargetApi 21
// noinspection UnnecessaryQualifiedReference
def versionsData = new groovy.json.JsonSlurper().parse(new File('metadata/versions.json'))
def versions = versionsData.versions.findAll { it.code == versionCode && it.name == versionName }
if (versions.size() != 1) {
throw new RuntimeException('Invalid metadata: ' + versions.size() + ' ' +
'version declarations for ' + versionCode + ' ' + versionName)
}
buildConfigField 'String', 'VERSION_DATE', '"' + versions[0].date + '"'
buildConfigField 'String', 'URI_UPDATES', '"//raw.githubusercontent.com/' +
'Mishiranu/Dashchan/master/update/data.json"'
buildConfigField 'String', 'URI_THEMES', '"//raw.githubusercontent.com/' +
'Mishiranu/Dashchan/master/update/themes.json"'
buildConfigField 'String', 'GITHUB_URI_METADATA', '"//github.com/Mishiranu/Dashchan"'
buildConfigField 'String', 'GITHUB_PATH_METADATA', '"metadata"'
}
sourceSets.main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = []
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res', 'lang']
assets.srcDirs = ['assets']
jni.srcDirs = []
jniLibs.srcDirs = []
}
def locales = sourceSets.main.res.srcDirs
.collectMany { (it.listFiles() ?: []) as Collection }
.findAll { it.getName().startsWith('values-') && new File(it, 'strings.xml').exists() }
.collect { it.getName().with { it.substring(it.indexOf('-') + 1) } }.sort()
defaultConfig {
buildConfigField 'String[]', 'LOCALES', '{"' + locales.join('", "') + '"}'
resConfigs locales
}
defaultConfig.ndk.abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86'
externalNativeBuild.ndkBuild.path 'jni/Android.mk'
buildTypes.create('leak').debuggable true
buildTypes.create('ndebug').debuggable true
def keystoreProperties = new Properties()
try {
file('keystore.properties').newInputStream().withCloseable { keystoreProperties.load(it) }
} catch (IOException ignored) {
// Ignore
}
def storeFile = keystoreProperties['store.file'].with { it != null ? file(it) : null }
def storePassword = keystoreProperties['store.password']
def keyAlias = keystoreProperties['key.alias']
def keyPassword = keystoreProperties['key.password']
def signerName = keystoreProperties['signer.name']
if (storeFile != null && storeFile.exists() && storePassword != null) {
def apksigner = new File(sdkDirectory, "build-tools/$buildToolsVersion/lib/apksigner.jar")
buildTypes.all { signingConfig null }
applicationVariants.all { variant ->
if (variant.outputs.size() != 1) {
throw new IllegalStateException()
}
def output = variant.outputs[0]
def unsignedName = output.outputFileName
if (!unsignedName.contains('-unsigned')) {
throw new IllegalStateException()
}
variant.outputsAreSigned true
output.outputFileName unsignedName.replace('-unsigned', '')
packageApplicationProvider.configure { packageTask ->
def outputDirectory = packageTask.outputDirectory.get().asFile
def file = new File(outputDirectory, output.outputFileName)
packageTask.doLast {
def args = ['sign', '--in', file.path, '--out', file.path]
args += ['--v4-signing-enabled', 'false']
args += ['--ks', storeFile.path, '--ks-pass', "pass:$storePassword"]
if (keyAlias != null && keyPassword != null) {
args += ['--ks-key-alias', keyAlias, '--key-pass', "pass:$keyPassword"]
}
if (signerName != null) {
args += ['--v1-signer-name', signerName]
}
javaexec {
classpath files(apksigner)
it.args args
}.rethrowFailure().assertNormalExitValue()
}
}
}
}
buildTypes.all {
crunchPngs false
minifyEnabled !debuggable
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude '/lib/*/libavcodec.so'
exclude '/lib/*/libavformat.so'
exclude '/lib/*/libavutil.so'
exclude '/lib/*/libswresample.so'
exclude '/lib/*/libswscale.so'
exclude '/lib/*/libyuv.so'
exclude '/META-INF/*.version'
}
lintOptions {
disable 'MissingTranslation', 'ValidFragment', 'ResourceType'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
leakImplementation 'com.squareup.leakcanary:leakcanary-android:2.5'
compileOnly 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
implementation 'com.fasterxml.jackson.core:jackson-core:2.11.3'
implementation 'androidx.fragment:fragment:1.2.5'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
implementation 'androidx.webkit:webkit:1.4.0'
implementation 'org.brotli:dec:0.1.2'
}
afterEvaluate {
task cxxClean(type: Delete) {
delete '.cxx'
}
tasks.getByName('clean').dependsOn(cxxClean)
tasks.findAll { it.name.startsWith('externalNativeBuildClean') }
.forEach { cxxClean.dependsOn(it) }
}