LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / android / source / build.gradle
bloba690749ff0eef8fbcf4882210647ac74446cf33c
1 apply plugin: 'com.android.application'
2 // buildhost settings - paths and the like
3 apply from: 'liboSettings.gradle'
5 project.ext.set("archivesBaseName", "LibreOfficeViewer")
6 allprojects {
7     repositories {
8         jcenter()
9         google()
10     }
12 //build-time dependencies - android plugin for gradle
13 buildscript {
14     repositories {
15         jcenter()
16         google()
17     }
18     dependencies {
19         classpath 'com.android.tools.build:gradle:3.6.1'
20     }
23 // compile-time dependencies
24 dependencies {
25     implementation fileTree(dir: "${liboInstdir}/${liboUREJavaFolder}", include: [
26             "java_uno.jar",
27             "libreoffice.jar",
28             "unoloader.jar"
29     ])
30     implementation 'com.android.support:design:27.1.1' // also pulls-in corresponding support libraries
31     implementation 'com.android.support.constraint:constraint-layout:1.1.2'
34 android {
35     compileSdkVersion 28
36     compileOptions {
37         // silence some java-language features hints
38         sourceCompatibility 6
39     }
40     // uses non-conventional source layout, so need to reconfigure accordingly
41     // ToDo move to conventional layout, so stuff can be stripped down.
42     sourceSets {
43         main.manifest.srcFile 'AndroidManifest.xml'
44         main.assets.srcDirs = ['assets']
45         main.res.srcDirs = ['res', 'res_generated']
46         main.java.srcDirs = ['../Bootstrap/src', 'src/java']
47         main.jniLibs.srcDirs = ["${liboJniLibsdir}"]
48         main.jni.srcDirs = [] // don't attempt to build native-lib via gradle
49         // the configuration data that might be stripped or not
50         fullUI.assets.srcDirs 'assets_fullUI'
51         strippedUI.assets.srcDirs 'assets_strippedUI'
52         strippedUIEditing.assets.srcDirs 'assets_strippedUI'
53     }
54     defaultConfig {
55         minSdkVersion 16
56         targetSdkVersion 28
57         vectorDrawables.useSupportLibrary = true
58     }
59     buildTypes {
60         debug {
61             // make android studio happy...
62             jniDebuggable true
63             // would work just fine with external, but setting emulator up is a little more work
64             manifestPlaceholders = [installLocation: "auto"]
65         }
66         release {
67             manifestPlaceholders = [installLocation: "preferExternal"]
68         }
69     }
71     flavorDimensions "default"
72     productFlavors {
73         strippedUI {
74             dimension "default"
75             buildConfigField 'boolean', 'ALLOW_EDITING', 'false'
76         }
77         strippedUIEditing {
78             dimension "default"
79             buildConfigField 'boolean', 'ALLOW_EDITING', 'true'
80             versionNameSuffix "-editing"
81         }
82         fullUI.dimension "default"
83     }
84     lintOptions {
85         // don't error-out on missing translations
86         warning 'MissingTranslation'
87     }
90 /* remark inherited from makefile:
91 Then "assets". Let the directory structure under assets mimic
92 that under solver for now.
94 Please note that I have no idea what all of this is really necessary and for
95 much of this stuff being copied, no idea whether it makes any sense at all.
96 Much of this is copy-pasted from android/qa/sc/Makefile (where a couple of
97 unit tests for sc are built, and those do seem to mostly work) and
98 android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
99 extent)
100  */
102 // Assets that are unpacked at run-time into the app's data directory. These
103 // are files read by non-LO code, fontconfig and freetype for now, that doesn't
104 // understand "/assets" paths.
105 task copyUnpackAssets(type: Copy) {
106     description "copies assets that need to be extracted on the device"
107     into 'assets/unpack'
108     into('program') {
109         from("${liboInstdir}/${liboEtcFolder}/types") {
110             includes = [
111                     "offapi.rdb",
112                     "oovbaapi.rdb"
113             ]
114         }
115         from("${liboInstdir}/${liboUreMiscFolder}") {
116             includes = ["types.rdb"]
117             rename 'types.rdb', 'udkapi.rdb'
118         }
119     }
120     into('user/fonts') {
121         from "${liboInstdir}/share/fonts/truetype"
122         // Note: restrict list of fonts due to size considerations - no technical reason anymore
123         // ToDo: fonts would be good candidate for using Expansion Files instead
124         includes = [
125                 "Liberation*.ttf",
126                 "Caladea-*.ttf",
127                 "Carlito-*.ttf",
128                 "Gen*.ttf",
129                 "opens___.ttf"
130         ]
131     }
132     into('etc/fonts') {
133         from "./"
134         includes = ['fonts.conf']
135         filter {
136             String line ->
137                 line.replaceAll(
138                         '@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}")
139                 )
140         }
141     }
144 task copyAssets(type: Copy) {
145     description "copies assets that can be accessed within the installed apk"
146     into 'assets'
148     // include icons
149     into ('share') {
150         into ('config') {
151             from ("${liboInstdir}/share/config")
152             includes = ['images_**.zip']
153         }
154     }
156     into('program') {
157         from "${liboInstdir}/program"
158         includes = ['services.rdb', 'services/services.rdb']
160         into('resource') {
161             from "${liboInstdir}/${liboSharedResFolder}"
162             includes = ['*en-US.res']
163         }
164     }
165     into('share') {
166         from("${liboInstdir}/share") {
167             // Filter data is needed by e.g. the drawingML preset shape import.
168             includes = ['registry/**', 'filter/**']
169             // those two get processed by mobile-config.py
170             excludes = ['registry/main.xcd', 'registry/res/registry_en-US.xcd']
171         }
172         // separate data files for Chinese and Japanese
173         from("${liboWorkdir}/CustomTarget/i18npool/breakiterator/") {
174             include '*.data'
175         }
176     }
177     // include required .ui files
178     into('config') {
179         from "${liboInstdir}/share/config"
180         include '**/annotation.ui',
181                 '**/hfmenubutton.ui',
182                 '**/inforeadonlydialog.ui',
183                 '**/pbmenubutton.ui',
184                 '**/tabbuttons.ui', '**/tabviewbar.ui'
185     }
188 task copyAppResources(type: Copy) {
189     description "copies documents to make them available as app resources"
190     into 'res_generated/raw'
191     from("${liboInstdir}") {
192         includes = ["LICENSE", "NOTICE"]
193         rename "LICENSE", "license.txt"
194         rename "NOTICE", "notice.txt"
195     }
196     from("${liboExampleDocument}") {
197         rename ".*", "example.odt"
198     }
201 task createFullConfig(type: Copy) {
202     // grab dir to clear whole hierarchy on clean target
203     outputs.dir "assets_fullUI"
204     into 'assets_fullUI/share/config/soffice.cfg'
205     from "${liboInstdir}/share/config/soffice.cfg"
208 task createStrippedConfig {
209     def preserveDir = file("assets_strippedUI/share/config/soffice.cfg/empty")
210     outputs.dir "assets_strippedUI"
211     outputs.dir "assets_strippedUI/share/registry/res"
212     outputs.file preserveDir
214     doLast {
215         file('assets_strippedUI/share/registry/res').mkdirs()
216         file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
217         // just empty file
218         preserveDir.text = ""
219     }
223 task createStrippedConfigMain(type: Exec) {
224     dependsOn 'createStrippedConfig'
225     inputs.files "${liboInstdir}/share/registry/main.xcd", "${liboSrcRoot}/android/mobile-config.py"
226     outputs.file "assets_strippedUI/share/registry/main.xcd"
227     executable "${liboSrcRoot}/android/mobile-config.py"
228     args = ["${liboInstdir}/share/registry/main.xcd", "assets_strippedUI/share/registry/main.xcd"]
231 task createStrippedConfigRegistry(type: Exec) {
232     dependsOn 'createStrippedConfig'
233     inputs.files "${liboInstdir}/share/registry/res/registry_en-US.xcd", "${liboSrcRoot}/android/mobile-config.py"
234     outputs.file "assets_strippedUI/share/registry/res/registry_en-US.xcd"
235     executable "${liboSrcRoot}/android/mobile-config.py"
236     args = ["${liboInstdir}/share/registry/res/registry_en-US.xcd", "assets_strippedUI/share/registry/res/registry_en-US.xcd"]
237     doFirst {
238         file('assets_strippedUI/share/registry/res').mkdirs()
239     }
242 task createRCfiles {
243     inputs.file "liboSettings.gradle"
244     dependsOn copyUnpackAssets, copyAssets
245     def sofficerc     = file('assets/unpack/program/sofficerc')
246     def fundamentalrc = file('assets/program/fundamentalrc')
247     def bootstraprc   = file('assets/program/bootstraprc')
248     def unorc         = file('assets/program/unorc')
249     def versionrc     = file('assets/program/versionrc')
251     outputs.files sofficerc, fundamentalrc, unorc, bootstraprc, versionrc
253     doLast {
254         sofficerc.text = '''\
255             [Bootstrap]
256             Logo=1
257             NativeProgress=1
258             URE_BOOTSTRAP=file:///assets/program/fundamentalrc
259             HOME=$APP_DATA_DIR/cache
260             OSL_SOCKET_PATH=$APP_DATA_DIR/cache
261             '''.stripIndent()
263         fundamentalrc.text =  '''\
264             [Bootstrap]
265             LO_LIB_DIR=file://$APP_DATA_DIR/lib/
266             BRAND_BASE_DIR=file:///assets
267             CONFIGURATION_LAYERS=xcsxcu:${BRAND_BASE_DIR}/share/registry res:${BRAND_BASE_DIR}/share/registry
268             URE_BIN_DIR=file:///assets/ure/bin/dir/nothing-here/we-can/exec-anyway
269             '''.stripIndent()
271         bootstraprc.text =  '''\
272             [Bootstrap]
273             InstallMode=<installmode>
274             ProductKey=LibreOffice '''+ "${liboVersionMajor}.${liboVersionMinor}" + '''
275             UserInstallation=file://$APP_DATA_DIR
276             '''.stripIndent()
278         unorc.text = '''\
279             [Bootstrap]
280             URE_INTERNAL_LIB_DIR=file://$APP_DATA_DIR/lib/
281             UNO_TYPES=file://$APP_DATA_DIR/program/udkapi.rdb file://$APP_DATA_DIR/program/offapi.rdb file://$APP_DATA_DIR/program/oovbaapi.rdb
282             UNO_SERVICES=file:///assets/program/services.rdb file:///assets/program/services/services.rdb
283             '''.stripIndent()
285         versionrc.text = '''\
286             [Version]
287             AllLanguages=en-US
288             buildid=''' + "${liboGitFullCommit}" + '''
289             ReferenceOOoMajorMinor=4.1
290             '''.stripIndent()
291     }
294 // creating the UI stuff is cheap, don't bother only applying it for the flavor...
295 preBuild.dependsOn 'createRCfiles',
296         'createStrippedConfigMain',
297         'createStrippedConfigRegistry',
298         'createFullConfig',
299         'copyAppResources'
301 clean.dependsOn 'cleanCopyAssets',
302         'cleanCreateStrippedConfig',
303         'cleanCreateFullConfig'