@@ -5,7 +5,8 @@ buildscript {
5
5
}
6
6
7
7
dependencies {
8
- classpath ' com.android.tools.build:gradle:3.6.4'
8
+ classpath ' com.android.tools.build:gradle:4.1.3'
9
+ classpath ' chan.library:plugins:0'
9
10
}
10
11
}
11
12
@@ -15,195 +16,3 @@ allprojects {
15
16
mavenCentral()
16
17
}
17
18
}
18
-
19
- class GenerateFileTask extends DefaultTask {
20
- @Input String inputText
21
- @OutputFile File outputFile
22
-
23
- @TaskAction
24
- def action () {
25
- outputFile. write(inputText)
26
- }
27
- }
28
-
29
- def configureCommon (project , manifestFile ) {
30
- project. android {
31
- compileSdkVersion 30
32
- buildToolsVersion ' 30.0.2'
33
-
34
- defaultConfig {
35
- minSdkVersion 16
36
- targetSdkVersion 30
37
- }
38
-
39
- sourceSets. main {
40
- manifest. srcFile manifestFile
41
- java. srcDirs = [' src' ]
42
- resources. srcDirs = []
43
- aidl. srcDirs = [' src' ]
44
- renderscript. srcDirs = [' src' ]
45
- res. srcDirs = [' res' ]
46
- assets. srcDirs = [' assets' ]
47
- }
48
-
49
- compileOptions {
50
- sourceCompatibility JavaVersion . VERSION_1_8
51
- targetCompatibility JavaVersion . VERSION_1_8
52
- }
53
- }
54
- }
55
-
56
- project. ext. set ' configureLibrary' , { project ->
57
- project. apply plugin : ' com.android.library'
58
-
59
- def packageName = ' chan.library.' + project. name
60
- def xml = ' <?xml version="1.0" encoding="utf-8"?>\n ' +
61
- ' <manifest xmlns:android="http://schemas.android.com/apk/res/android" ' +
62
- " package=\" $packageName \" />"
63
-
64
- def manifestFile = new File (project. buildDir, ' generated/AndroidManifest.xml' )
65
- if (! manifestFile. exists()) {
66
- // Fixes IntelliJ Android plugin error
67
- manifestFile. parentFile. mkdirs()
68
- manifestFile. write(xml)
69
- }
70
-
71
- project. preBuild. dependsOn(project. task(' generateManifest' , type : GenerateFileTask ) {
72
- inputText = xml
73
- outputFile = manifestFile
74
- })
75
-
76
- configureCommon(project, manifestFile)
77
- }
78
-
79
- project. ext. set ' configureExtension' , { project , data ->
80
- project. apply plugin : ' com.android.application'
81
-
82
- def keyNotFound = { throw new NullPointerException (it + ' is not defined' ) }
83
-
84
- def chanName = project. name
85
- def packageName = data[' packageName' ] ?: ' com.mishiranu.dashchan.chan.' + chanName
86
- def chanNameUpper = data[' chanNameUpper' ] ?: chanName. take(1 ). toUpperCase() + chanName. substring(1 )
87
- def versionName = data[' versionName' ] ?: keyNotFound(' versionName' )
88
- def apiVersion = data[' apiVersion' ] ?: keyNotFound(' apiVersion' )
89
- def icon = data[' icon' ] ?: ' ic_custom_' + chanName
90
- def updateUri = data[' updateUri' ] ?: ' //raw.githubusercontent.com/Mishiranu/Dashchan/master/update/data.json'
91
- def hosts = data[' hosts' ] ?: keyNotFound(' hosts' )
92
- def customUriHandler = data[' customFilter' ] ?: false
93
- def customFilter = data[' customFilter' ]
94
- def chanTitle = hosts[0 ]
95
-
96
- def requiredClasses = [' ChanConfiguration' , ' ChanLocator' , ' ChanMarkup' , ' ChanPerformer' ]
97
- .collect { packageName + ' .' + chanNameUpper + it }
98
-
99
- def xml = ' <?xml version="1.0" encoding="utf-8"?>\n ' +
100
- ' <manifest xmlns:android="http://schemas.android.com/apk/res/android" ' +
101
- " package=\" $packageName \" android:versionCode=\" 1\" android:versionName=\" $versionName \" >\n "
102
- xml + = ' <uses-feature android:name="chan.extension" />\n '
103
- xml + = ' <application android:icon="@null" android:allowBackup="false" ' +
104
- " android:label=\" Dashchan for ${ chanTitle} \" >\n "
105
- xml + = " <meta-data android:name=\" chan.extension.name\" android:value=\" $chanName \" />\n "
106
- xml + = " <meta-data android:name=\" chan.extension.title\" android:value=\" ${ chanTitle} \" />\n "
107
- xml + = " <meta-data android:name=\" chan.extension.version\" android:value=\" $apiVersion \" />\n "
108
- xml + = " <meta-data android:name=\" chan.extension.icon\" android:resource=\" @drawable/$icon \" />\n "
109
- xml + = " <meta-data android:name=\" chan.extension.source\" android:value=\" $updateUri \" />\n "
110
- xml + = ' <meta-data android:name="chan.extension.class.configuration" ' +
111
- " android:value=\" .${ chanNameUpper} ChanConfiguration\" />\n "
112
- xml + = ' <meta-data android:name="chan.extension.class.performer" ' +
113
- " android:value=\" .${ chanNameUpper} ChanPerformer\" />\n "
114
- xml + = ' <meta-data android:name="chan.extension.class.locator" ' +
115
- " android:value=\" .${ chanNameUpper} ChanLocator\" />\n "
116
- xml + = ' <meta-data android:name="chan.extension.class.markup" ' +
117
- " android:value=\" .${ chanNameUpper} ChanMarkup\" />\n "
118
- xml + = ' <activity android:name="chan.application.UriHandlerActivity" ' +
119
- ' android:label="Dashchan" android:theme="@android:style/Theme.NoDisplay">\n '
120
- xml + = ' <intent-filter>\n ' +
121
- ' <action android:name="android.intent.action.VIEW" />\n ' +
122
- ' <category android:name="android.intent.category.DEFAULT" />\n ' +
123
- ' <category android:name="android.intent.category.BROWSABLE" />\n '
124
- if (customFilter != null ) {
125
- xml + = customFilter
126
- } else {
127
- xml + = ' <data android:scheme="http" />\n ' +
128
- ' <data android:scheme="https" />\n '
129
- for (host in hosts) {
130
- xml + = " <data android:host=\" $host \" />\n "
131
- }
132
- }
133
- xml + = ' </intent-filter>\n </activity>\n </application>\n </manifest>\n '
134
-
135
- def proguard = ' -dontobfuscate\n ' + requiredClasses
136
- .collect { ' -keep class ' + it + ' { *; }\n ' }. join()
137
-
138
- def manifestFile = new File (project. buildDir, ' generated/AndroidManifest.xml' )
139
- def proguardFile = new File (project. buildDir, ' generated/proguard-rules.pro' )
140
- if (! manifestFile. exists()) {
141
- // Fixes IntelliJ Android plugin error
142
- manifestFile. parentFile. mkdirs()
143
- manifestFile. write(' <?xml version="1.0" encoding="utf-8"?>\n ' +
144
- ' <manifest xmlns:android="http://schemas.android.com/apk/res/android" ' +
145
- " package=\" $packageName \" />" )
146
- }
147
-
148
- project. preBuild. dependsOn(project. task(' generateManifest' , type : GenerateFileTask ) {
149
- inputText = xml
150
- outputFile = manifestFile
151
- })
152
- project. preBuild. dependsOn(project. task(' generateProguard' , type : GenerateFileTask ) {
153
- inputText = proguard
154
- outputFile = proguardFile
155
- })
156
-
157
- project. archivesBaseName = ' Dashchan' + chanNameUpper
158
- configureCommon(project, manifestFile)
159
-
160
- project. android {
161
- defaultConfig {
162
- // Don't warn about unused classes
163
- buildConfigField ' Class[]' , ' USED_CLASSES' ,
164
- ' {' + requiredClasses. collect { it + ' .class' }. join(' , ' ) + ' }'
165
- }
166
-
167
- if (file(' keystore.properties' ). exists()) {
168
- def keystoreProperties = new Properties ()
169
- keystoreProperties. load(new FileInputStream (file(' keystore.properties' )))
170
-
171
- signingConfigs {
172
- general {
173
- storeFile file(keystoreProperties[' store.file' ])
174
- storePassword keystoreProperties[' store.password' ]
175
- keyAlias keystoreProperties[' key.alias' ]
176
- keyPassword keystoreProperties[' key.password' ]
177
- }
178
- }
179
-
180
- buildTypes. debug. signingConfig signingConfigs. general
181
- buildTypes. release. signingConfig signingConfigs. general
182
- }
183
-
184
- buildTypes {
185
- debug {
186
- minifyEnabled false
187
- }
188
- release {
189
- minifyEnabled true
190
- }
191
- all {
192
- crunchPngs false
193
- proguardFiles getDefaultProguardFile(' proguard-android.txt' ), proguardFile
194
- }
195
- }
196
-
197
- lintOptions {
198
- abortOnError false
199
- disable ' MissingTranslation'
200
- }
201
- }
202
-
203
- project. dependencies {
204
- compileOnly project. project(' :libraries:api' )
205
- if (! customUriHandler) {
206
- implementation project. project(' :libraries:urihandler' )
207
- }
208
- }
209
- }
0 commit comments