1 apply plugin: 'com.android.application'
2 // buildhost settings - paths and the like
3 apply from: 'liboSettings.gradle'
5 project.ext.set("archivesBaseName", "LibreOfficeViewer")
9 url "https://maven.google.com"
12 dirs "${liboWorkdir}/UnpackedTarball/owncloud_android_lib/build/outputs/aar"
16 //build-time dependencies - android plugin for gradle
21 url "https://maven.google.com"
25 classpath 'com.android.tools.build:gradle:3.0.1'
29 // compile-time dependencies
31 implementation fileTree(dir: "${liboInstdir}/${liboUREJavaFolder}", include: [
38 implementation files("${liboInstdir}/${liboShareJavaFolder}/unoil.jar")
39 debugImplementation(name:'owncloud_android_lib-debug', ext:'aar')
40 releaseImplementation(name:'owncloud_android_lib-release', ext:'aar')
41 implementation 'com.android.support:design:27.0.1' // also pulls-in corresponding support libraries
42 implementation 'com.android.support.constraint:constraint-layout:1.0.2'
47 buildToolsVersion "27.0.1"
49 // silence some java-language features hints
52 // uses non-conventional source layout, so need to reconfigure accordingly
53 // ToDo move to conventional layout, so stuff can be stripped down.
55 main.manifest.srcFile 'AndroidManifest.xml'
56 main.assets.srcDirs = ['assets']
57 main.res.srcDirs = ['res']
58 main.java.srcDirs = ['../Bootstrap/src', 'src/java']
59 main.jniLibs.srcDirs = ['jniLibs']
60 main.jni.srcDirs = [] // don't attempt to build native-lib via gradle
61 // the configuration data that might be stripped or not
62 fullUI.assets.srcDirs 'assets_fullUI'
63 strippedUI.assets.srcDirs 'assets_strippedUI'
68 vectorDrawables.useSupportLibrary = true
72 // make android studio happy...
74 // would work just fine with external, but setting emulator up is a little more work
75 manifestPlaceholders = [installLocation: "auto", extractNativeLibs: "false"]
78 // need to extract native libs (allow to compress them in apk), since otherwise would
79 // exceed maximum size for playstore
80 manifestPlaceholders = [installLocation: "preferExternal", extractNativeLibs: "true"]
84 flavorDimensions "default"
86 strippedUI.dimension "default"
87 fullUI.dimension "default"
91 /* remark inherited from makefile:
92 Then "assets". Let the directory structure under assets mimic
93 that under solver for now.
95 Please note that I have no idea what all of this is really necessary and for
96 much of this stuff being copied, no idea whether it makes any sense at all.
97 Much of this is copy-pasted from android/qa/sc/Makefile (where a couple of
98 unit tests for sc are built, and those do seem to mostly work) and
99 android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
103 // Assets that are unpacked at run-time into the app's data directory. These
104 // are files read by non-LO code, fontconfig and freetype for now, that doesn't
105 // understand "/assets" paths.
106 task copyUnpackAssets(type: Copy) {
107 description "copies assets that need to be extracted on the device"
110 from("${liboInstdir}/${liboEtcFolder}/types") {
116 from("${liboInstdir}/${liboUreMiscFolder}") {
117 includes = ["types.rdb"]
118 rename 'types.rdb', 'udkapi.rdb'
122 from "${liboInstdir}/share/fonts/truetype"
123 // Note: restrict list of fonts due to size considerations - no technical reason anymore
124 // ToDo: fonts would be good candidate for using Expansion Files instead
135 includes = ['fonts.conf']
139 '@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}")
145 task copyAssets(type: Copy) {
146 description "copies assets that can be accessed within the installed apk"
148 from("${liboSrcRoot}/readlicense_oo/license/") {
149 includes = ["LICENSE", "NOTICE"]
150 rename "LICENSE", "license.txt"
151 rename "NOTICE", "notice.txt"
153 from("${liboExampleDocument}") {
154 rename ".*", "example.odt"
157 from "${liboInstdir}/program"
158 includes = ['services.rdb', 'services/services.rdb']
161 from "${liboInstdir}/${liboSharedResFolder}"
162 includes = ['*en-US.res']
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']
174 task createFullConfig(type: Copy) {
175 // grab dir to clear whole hierarchy on clean target
176 outputs.dir "assets_fullUI"
177 into 'assets_fullUI/share/config/soffice.cfg'
178 from "${liboInstdir}/share/config/soffice.cfg"
181 task createStrippedConfig {
182 def preserveDir = file("assets_strippedUI/share/config/soffice.cfg/empty")
183 outputs.dir "assets_strippedUI"
184 outputs.dir "assets_strippedUI/share/registry/res"
185 outputs.file preserveDir
188 file('assets_strippedUI/share/registry/res').mkdirs()
189 file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
191 preserveDir.text = ""
196 task createStrippedConfigMain(type: Exec) {
197 dependsOn 'createStrippedConfig'
198 inputs.files "${liboInstdir}/share/registry/main.xcd", "${liboSrcRoot}/android/mobile-config.py"
199 outputs.file "assets_strippedUI/share/registry/main.xcd"
200 executable "${liboSrcRoot}/android/mobile-config.py"
201 args = ["${liboInstdir}/share/registry/main.xcd", "assets_strippedUI/share/registry/main.xcd"]
204 task createStrippedConfigRegistry(type: Exec) {
205 dependsOn 'createStrippedConfig'
206 inputs.files "${liboInstdir}/share/registry/res/registry_en-US.xcd", "${liboSrcRoot}/android/mobile-config.py"
207 outputs.file "assets_strippedUI/share/registry/res/registry_en-US.xcd"
208 executable "${liboSrcRoot}/android/mobile-config.py"
209 args = ["${liboInstdir}/share/registry/res/registry_en-US.xcd", "assets_strippedUI/share/registry/res/registry_en-US.xcd"]
211 file('assets_strippedUI/share/registry/res').mkdirs()
216 inputs.file "liboSettings.gradle"
217 dependsOn copyUnpackAssets, copyAssets
218 def sofficerc = file('assets/unpack/program/sofficerc')
219 def fundamentalrc = file('assets/program/fundamentalrc')
220 def bootstraprc = file('assets/program/bootstraprc')
221 def unorc = file('assets/program/unorc')
222 def versionrc = file('assets/program/versionrc')
224 outputs.files sofficerc, fundamentalrc, unorc, bootstraprc, versionrc
227 sofficerc.text = '''\
231 URE_BOOTSTRAP=file:///assets/program/fundamentalrc
232 HOME=$APP_DATA_DIR/cache
233 OSL_SOCKET_PATH=$APP_DATA_DIR/cache
236 fundamentalrc.text = '''\
238 LO_LIB_DIR=file://$APP_DATA_DIR/lib/
239 BRAND_BASE_DIR=file:///assets
240 CONFIGURATION_LAYERS=xcsxcu:${BRAND_BASE_DIR}/share/registry res:${BRAND_BASE_DIR}/share/registry
241 URE_BIN_DIR=file:///assets/ure/bin/dir/nothing-here/we-can/exec-anyway
244 bootstraprc.text = '''\
246 InstallMode=<installmode>
247 ProductKey=LibreOffice '''+ "${liboVersionMajor}.${liboVersionMinor}" + '''
248 UserInstallation=file://$APP_DATA_DIR
253 URE_INTERNAL_LIB_DIR=file://$APP_DATA_DIR/lib/
254 UNO_TYPES=file://$APP_DATA_DIR/program/udkapi.rdb file://$APP_DATA_DIR/program/offapi.rdb file://$APP_DATA_DIR/program/oovbaapi.rdb
255 UNO_SERVICES=file:///assets/program/services.rdb file:///assets/program/services/services.rdb
258 versionrc.text = '''\
262 buildid=''' + "${liboGitFullCommit}" + '''
263 ReferenceOOoMajorMinor=4.1
268 // creating the UI stuff is cheap, don't bother only applying it for the flavor..
269 preBuild.dependsOn 'createRCfiles',
270 'createStrippedConfigMain',
271 'createStrippedConfigRegistry',
274 clean.dependsOn 'cleanCopyAssets',
275 'cleanCreateStrippedConfig',
276 'cleanCreateFullConfig'