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.1.3'
26 // compile-time dependencies
28 implementation fileTree(dir: "${liboInstdir}/${liboUREJavaFolder}", include: [
35 implementation files("${liboInstdir}/${liboShareJavaFolder}/unoil.jar")
36 debugImplementation(name:'owncloud_android_lib-debug', ext:'aar')
37 releaseImplementation(name:'owncloud_android_lib-release', ext:'aar')
38 implementation 'com.android.support:design:27.1.1' // also pulls-in corresponding support libraries
39 implementation 'com.android.support.constraint:constraint-layout:1.1.2'
44 buildToolsVersion "27.0.3"
46 // silence some java-language features hints
49 // uses non-conventional source layout, so need to reconfigure accordingly
50 // ToDo move to conventional layout, so stuff can be stripped down.
52 main.manifest.srcFile 'AndroidManifest.xml'
53 main.assets.srcDirs = ['assets']
54 main.res.srcDirs = ['res']
55 main.java.srcDirs = ['../Bootstrap/src', 'src/java']
56 main.jniLibs.srcDirs = ['jniLibs']
57 main.jni.srcDirs = [] // don't attempt to build native-lib via gradle
58 // the configuration data that might be stripped or not
59 fullUI.assets.srcDirs 'assets_fullUI'
60 strippedUI.assets.srcDirs 'assets_strippedUI'
61 strippedUIEditing.assets.srcDirs 'assets_strippedUI'
66 vectorDrawables.useSupportLibrary = true
70 // make android studio happy...
72 // would work just fine with external, but setting emulator up is a little more work
73 manifestPlaceholders = [installLocation: "auto", extractNativeLibs: "false"]
76 // need to extract native libs (allow to compress them in apk), since otherwise would
77 // exceed maximum size for playstore
78 manifestPlaceholders = [installLocation: "preferExternal", extractNativeLibs: "true"]
82 flavorDimensions "default"
86 buildConfigField 'boolean', 'ALLOW_EDITING', 'false'
90 buildConfigField 'boolean', 'ALLOW_EDITING', 'true'
91 versionNameSuffix "-editing"
93 fullUI.dimension "default"
97 /* remark inherited from makefile:
98 Then "assets". Let the directory structure under assets mimic
99 that under solver for now.
101 Please note that I have no idea what all of this is really necessary and for
102 much of this stuff being copied, no idea whether it makes any sense at all.
103 Much of this is copy-pasted from android/qa/sc/Makefile (where a couple of
104 unit tests for sc are built, and those do seem to mostly work) and
105 android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
109 // Assets that are unpacked at run-time into the app's data directory. These
110 // are files read by non-LO code, fontconfig and freetype for now, that doesn't
111 // understand "/assets" paths.
112 task copyUnpackAssets(type: Copy) {
113 description "copies assets that need to be extracted on the device"
116 from("${liboInstdir}/${liboEtcFolder}/types") {
122 from("${liboInstdir}/${liboUreMiscFolder}") {
123 includes = ["types.rdb"]
124 rename 'types.rdb', 'udkapi.rdb'
128 from "${liboInstdir}/share/fonts/truetype"
129 // Note: restrict list of fonts due to size considerations - no technical reason anymore
130 // ToDo: fonts would be good candidate for using Expansion Files instead
141 includes = ['fonts.conf']
145 '@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}")
151 task copyAssets(type: Copy) {
152 description "copies assets that can be accessed within the installed apk"
154 from("${liboSrcRoot}/readlicense_oo/license/") {
155 includes = ["LICENSE", "NOTICE"]
156 rename "LICENSE", "license.txt"
157 rename "NOTICE", "notice.txt"
159 from("${liboExampleDocument}") {
160 rename ".*", "example.odt"
163 from "${liboInstdir}/program"
164 includes = ['services.rdb', 'services/services.rdb']
167 from "${liboInstdir}/${liboSharedResFolder}"
168 includes = ['*en-US.res']
172 from "${liboInstdir}/share"
173 // Filter data is needed by e.g. the drawingML preset shape import.
174 includes = ['registry/**', 'filter/**']
175 // those two get processed by mobile-config.py
176 excludes = ['registry/main.xcd', 'registry/res/registry_en-US.xcd']
180 task createFullConfig(type: Copy) {
181 // grab dir to clear whole hierarchy on clean target
182 outputs.dir "assets_fullUI"
183 into 'assets_fullUI/share/config/soffice.cfg'
184 from "${liboInstdir}/share/config/soffice.cfg"
187 task createStrippedConfig {
188 def preserveDir = file("assets_strippedUI/share/config/soffice.cfg/empty")
189 outputs.dir "assets_strippedUI"
190 outputs.dir "assets_strippedUI/share/registry/res"
191 outputs.file preserveDir
194 file('assets_strippedUI/share/registry/res').mkdirs()
195 file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
197 preserveDir.text = ""
202 task createStrippedConfigMain(type: Exec) {
203 dependsOn 'createStrippedConfig'
204 inputs.files "${liboInstdir}/share/registry/main.xcd", "${liboSrcRoot}/android/mobile-config.py"
205 outputs.file "assets_strippedUI/share/registry/main.xcd"
206 executable "${liboSrcRoot}/android/mobile-config.py"
207 args = ["${liboInstdir}/share/registry/main.xcd", "assets_strippedUI/share/registry/main.xcd"]
210 task createStrippedConfigRegistry(type: Exec) {
211 dependsOn 'createStrippedConfig'
212 inputs.files "${liboInstdir}/share/registry/res/registry_en-US.xcd", "${liboSrcRoot}/android/mobile-config.py"
213 outputs.file "assets_strippedUI/share/registry/res/registry_en-US.xcd"
214 executable "${liboSrcRoot}/android/mobile-config.py"
215 args = ["${liboInstdir}/share/registry/res/registry_en-US.xcd", "assets_strippedUI/share/registry/res/registry_en-US.xcd"]
217 file('assets_strippedUI/share/registry/res').mkdirs()
222 inputs.file "liboSettings.gradle"
223 dependsOn copyUnpackAssets, copyAssets
224 def sofficerc = file('assets/unpack/program/sofficerc')
225 def fundamentalrc = file('assets/program/fundamentalrc')
226 def bootstraprc = file('assets/program/bootstraprc')
227 def unorc = file('assets/program/unorc')
228 def versionrc = file('assets/program/versionrc')
230 outputs.files sofficerc, fundamentalrc, unorc, bootstraprc, versionrc
233 sofficerc.text = '''\
237 URE_BOOTSTRAP=file:///assets/program/fundamentalrc
238 HOME=$APP_DATA_DIR/cache
239 OSL_SOCKET_PATH=$APP_DATA_DIR/cache
242 fundamentalrc.text = '''\
244 LO_LIB_DIR=file://$APP_DATA_DIR/lib/
245 BRAND_BASE_DIR=file:///assets
246 CONFIGURATION_LAYERS=xcsxcu:${BRAND_BASE_DIR}/share/registry res:${BRAND_BASE_DIR}/share/registry
247 URE_BIN_DIR=file:///assets/ure/bin/dir/nothing-here/we-can/exec-anyway
250 bootstraprc.text = '''\
252 InstallMode=<installmode>
253 ProductKey=LibreOffice '''+ "${liboVersionMajor}.${liboVersionMinor}" + '''
254 UserInstallation=file://$APP_DATA_DIR
259 URE_INTERNAL_LIB_DIR=file://$APP_DATA_DIR/lib/
260 UNO_TYPES=file://$APP_DATA_DIR/program/udkapi.rdb file://$APP_DATA_DIR/program/offapi.rdb file://$APP_DATA_DIR/program/oovbaapi.rdb
261 UNO_SERVICES=file:///assets/program/services.rdb file:///assets/program/services/services.rdb
264 versionrc.text = '''\
268 buildid=''' + "${liboGitFullCommit}" + '''
269 ReferenceOOoMajorMinor=4.1
274 // creating the UI stuff is cheap, don't bother only applying it for the flavor..
275 preBuild.dependsOn 'createRCfiles',
276 'createStrippedConfigMain',
277 'createStrippedConfigRegistry',
280 clean.dependsOn 'cleanCopyAssets',
281 'cleanCreateStrippedConfig',
282 'cleanCreateFullConfig'