1 apply plugin: 'com.android.application'
2 // buildhost settings - paths and the like
3 apply from: 'liboSettings.gradle'
5 project.ext.set("archivesBaseName", "LibreOfficeViewer")
11 dirs "${liboWorkdir}/UnpackedTarball/owncloud_android_lib/build/outputs/aar"
15 //build-time dependencies - android plugin for gradle
22 classpath 'com.android.tools.build:gradle:3.6.1'
26 // compile-time dependencies
28 implementation fileTree(dir: "${liboInstdir}/${liboUREJavaFolder}", include: [
33 implementation(name:'owncloud_android_lib', ext:'aar')
34 implementation 'com.android.support:design:27.1.1' // also pulls-in corresponding support libraries
35 implementation 'com.android.support.constraint:constraint-layout:1.1.2'
41 // silence some java-language features hints
44 // uses non-conventional source layout, so need to reconfigure accordingly
45 // ToDo move to conventional layout, so stuff can be stripped down.
47 main.manifest.srcFile 'AndroidManifest.xml'
48 main.assets.srcDirs = ['assets']
49 main.res.srcDirs = ['res']
50 main.java.srcDirs = ['../Bootstrap/src', 'src/java']
51 main.jniLibs.srcDirs = ["${liboJniLibsdir}"]
52 main.jni.srcDirs = [] // don't attempt to build native-lib via gradle
53 // the configuration data that might be stripped or not
54 fullUI.assets.srcDirs 'assets_fullUI'
55 strippedUI.assets.srcDirs 'assets_strippedUI'
56 strippedUIEditing.assets.srcDirs 'assets_strippedUI'
61 vectorDrawables.useSupportLibrary = true
65 // make android studio happy...
67 // would work just fine with external, but setting emulator up is a little more work
68 manifestPlaceholders = [installLocation: "auto"]
71 manifestPlaceholders = [installLocation: "preferExternal"]
75 flavorDimensions "default"
79 buildConfigField 'boolean', 'ALLOW_EDITING', 'false'
83 buildConfigField 'boolean', 'ALLOW_EDITING', 'true'
84 versionNameSuffix "-editing"
86 fullUI.dimension "default"
89 // don't error-out on missing translations
90 warning 'MissingTranslation'
94 /* remark inherited from makefile:
95 Then "assets". Let the directory structure under assets mimic
96 that under solver for now.
98 Please note that I have no idea what all of this is really necessary and for
99 much of this stuff being copied, no idea whether it makes any sense at all.
100 Much of this is copy-pasted from android/qa/sc/Makefile (where a couple of
101 unit tests for sc are built, and those do seem to mostly work) and
102 android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
106 // Assets that are unpacked at run-time into the app's data directory. These
107 // are files read by non-LO code, fontconfig and freetype for now, that doesn't
108 // understand "/assets" paths.
109 task copyUnpackAssets(type: Copy) {
110 description "copies assets that need to be extracted on the device"
113 from("${liboInstdir}/${liboEtcFolder}/types") {
119 from("${liboInstdir}/${liboUreMiscFolder}") {
120 includes = ["types.rdb"]
121 rename 'types.rdb', 'udkapi.rdb'
125 from "${liboInstdir}/share/fonts/truetype"
126 // Note: restrict list of fonts due to size considerations - no technical reason anymore
127 // ToDo: fonts would be good candidate for using Expansion Files instead
138 includes = ['fonts.conf']
142 '@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}")
148 task copyAssets(type: Copy) {
149 description "copies assets that can be accessed within the installed apk"
151 from("${liboInstdir}") {
152 includes = ["LICENSE", "NOTICE"]
153 rename "LICENSE", "license.txt"
154 rename "NOTICE", "notice.txt"
156 from("${liboExampleDocument}") {
157 rename ".*", "example.odt"
163 from ("${liboInstdir}/share/config")
164 includes = ['images_**.zip']
169 from "${liboInstdir}/program"
170 includes = ['services.rdb', 'services/services.rdb']
173 from "${liboInstdir}/${liboSharedResFolder}"
174 includes = ['*en-US.res']
178 from("${liboInstdir}/share") {
179 // Filter data is needed by e.g. the drawingML preset shape import.
180 includes = ['registry/**', 'filter/**']
181 // those two get processed by mobile-config.py
182 excludes = ['registry/main.xcd', 'registry/res/registry_en-US.xcd']
184 // separate data files for Chinese and Japanese
185 from("${liboWorkdir}/CustomTarget/i18npool/breakiterator/") {
189 // documents with manual page break trigger attempt to read the ui file 'pagebreakmenu.ui'
190 // would trigger a css::container::NoSuchElementException with osl_File_E_NOENT
191 // if not present and since it is not caught would crash the app;
192 // 'annotationmenu.ui' required to handle documents containing comments,
193 // 'headerfootermenu.ui' when clicking inside header/footer of document
195 from "${liboInstdir}/share/config"
196 include '**/pagebreakmenu.ui', '**/annotationmenu.ui', '**/headerfootermenu.ui'
200 task createFullConfig(type: Copy) {
201 // grab dir to clear whole hierarchy on clean target
202 outputs.dir "assets_fullUI"
203 into 'assets_fullUI/share/config/soffice.cfg'
204 from "${liboInstdir}/share/config/soffice.cfg"
207 task createStrippedConfig {
208 def preserveDir = file("assets_strippedUI/share/config/soffice.cfg/empty")
209 outputs.dir "assets_strippedUI"
210 outputs.dir "assets_strippedUI/share/registry/res"
211 outputs.file preserveDir
214 file('assets_strippedUI/share/registry/res').mkdirs()
215 file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
217 preserveDir.text = ""
222 task createStrippedConfigMain(type: Exec) {
223 dependsOn 'createStrippedConfig'
224 inputs.files "${liboInstdir}/share/registry/main.xcd", "${liboSrcRoot}/android/mobile-config.py"
225 outputs.file "assets_strippedUI/share/registry/main.xcd"
226 executable "${liboSrcRoot}/android/mobile-config.py"
227 args = ["${liboInstdir}/share/registry/main.xcd", "assets_strippedUI/share/registry/main.xcd"]
230 task createStrippedConfigRegistry(type: Exec) {
231 dependsOn 'createStrippedConfig'
232 inputs.files "${liboInstdir}/share/registry/res/registry_en-US.xcd", "${liboSrcRoot}/android/mobile-config.py"
233 outputs.file "assets_strippedUI/share/registry/res/registry_en-US.xcd"
234 executable "${liboSrcRoot}/android/mobile-config.py"
235 args = ["${liboInstdir}/share/registry/res/registry_en-US.xcd", "assets_strippedUI/share/registry/res/registry_en-US.xcd"]
237 file('assets_strippedUI/share/registry/res').mkdirs()
242 inputs.file "liboSettings.gradle"
243 dependsOn copyUnpackAssets, copyAssets
244 def sofficerc = file('assets/unpack/program/sofficerc')
245 def fundamentalrc = file('assets/program/fundamentalrc')
246 def bootstraprc = file('assets/program/bootstraprc')
247 def unorc = file('assets/program/unorc')
248 def versionrc = file('assets/program/versionrc')
250 outputs.files sofficerc, fundamentalrc, unorc, bootstraprc, versionrc
253 sofficerc.text = '''\
257 URE_BOOTSTRAP=file:///assets/program/fundamentalrc
258 HOME=$APP_DATA_DIR/cache
259 OSL_SOCKET_PATH=$APP_DATA_DIR/cache
262 fundamentalrc.text = '''\
264 LO_LIB_DIR=file://$APP_DATA_DIR/lib/
265 BRAND_BASE_DIR=file:///assets
266 CONFIGURATION_LAYERS=xcsxcu:${BRAND_BASE_DIR}/share/registry res:${BRAND_BASE_DIR}/share/registry
267 URE_BIN_DIR=file:///assets/ure/bin/dir/nothing-here/we-can/exec-anyway
270 bootstraprc.text = '''\
272 InstallMode=<installmode>
273 ProductKey=LibreOffice '''+ "${liboVersionMajor}.${liboVersionMinor}" + '''
274 UserInstallation=file://$APP_DATA_DIR
279 URE_INTERNAL_LIB_DIR=file://$APP_DATA_DIR/lib/
280 UNO_TYPES=file://$APP_DATA_DIR/program/udkapi.rdb file://$APP_DATA_DIR/program/offapi.rdb file://$APP_DATA_DIR/program/oovbaapi.rdb
281 UNO_SERVICES=file:///assets/program/services.rdb file:///assets/program/services/services.rdb
284 versionrc.text = '''\
287 buildid=''' + "${liboGitFullCommit}" + '''
288 ReferenceOOoMajorMinor=4.1
293 // creating the UI stuff is cheap, don't bother only applying it for the flavor...
294 preBuild.dependsOn 'createRCfiles',
295 'createStrippedConfigMain',
296 'createStrippedConfigRegistry',
299 clean.dependsOn 'cleanCopyAssets',
300 'cleanCreateStrippedConfig',
301 'cleanCreateFullConfig'