1 apply plugin: 'com.android.application'
2 // buildhost settings - paths and the like
3 apply from: 'liboSettings.gradle'
5 project.ext.set("archivesBaseName", "LibreOfficeViewer")
12 //build-time dependencies - android plugin for gradle
19 classpath 'com.android.tools.build:gradle:3.6.1'
23 // compile-time dependencies
25 implementation fileTree(dir: "${liboInstdir}/${liboUREJavaFolder}", include: [
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'
37 // silence some java-language features hints
40 // uses non-conventional source layout, so need to reconfigure accordingly
41 // ToDo move to conventional layout, so stuff can be stripped down.
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'
57 vectorDrawables.useSupportLibrary = true
61 // make android studio happy...
63 // would work just fine with external, but setting emulator up is a little more work
64 manifestPlaceholders = [installLocation: "auto"]
67 manifestPlaceholders = [installLocation: "preferExternal"]
71 flavorDimensions "default"
75 buildConfigField 'boolean', 'ALLOW_EDITING', 'false'
79 buildConfigField 'boolean', 'ALLOW_EDITING', 'true'
80 versionNameSuffix "-editing"
82 fullUI.dimension "default"
85 // don't error-out on missing translations
86 warning 'MissingTranslation'
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
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"
109 from("${liboInstdir}/${liboEtcFolder}/types") {
115 from("${liboInstdir}/${liboUreMiscFolder}") {
116 includes = ["types.rdb"]
117 rename 'types.rdb', 'udkapi.rdb'
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
134 includes = ['fonts.conf']
138 '@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}")
144 task copyAssets(type: Copy) {
145 description "copies assets that can be accessed within the installed apk"
151 from ("${liboInstdir}/share/config")
152 includes = ['images_**.zip']
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']
172 // separate data files for Chinese and Japanese
173 from("${liboWorkdir}/CustomTarget/i18npool/breakiterator/") {
177 // include required .ui files
179 from "${liboInstdir}/share/config"
180 include '**/annotation.ui',
181 '**/hfmenubutton.ui',
182 '**/inforeadonlydialog.ui',
183 '**/pbmenubutton.ui',
184 '**/tabbuttons.ui', '**/tabviewbar.ui'
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"
196 from("${liboExampleDocument}") {
197 rename ".*", "example.odt"
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
215 file('assets_strippedUI/share/registry/res').mkdirs()
216 file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
218 preserveDir.text = ""
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"]
238 file('assets_strippedUI/share/registry/res').mkdirs()
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
254 sofficerc.text = '''\
258 URE_BOOTSTRAP=file:///assets/program/fundamentalrc
259 HOME=$APP_DATA_DIR/cache
260 OSL_SOCKET_PATH=$APP_DATA_DIR/cache
263 fundamentalrc.text = '''\
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
271 bootstraprc.text = '''\
273 InstallMode=<installmode>
274 ProductKey=LibreOffice '''+ "${liboVersionMajor}.${liboVersionMinor}" + '''
275 UserInstallation=file://$APP_DATA_DIR
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
285 versionrc.text = '''\
288 buildid=''' + "${liboGitFullCommit}" + '''
289 ReferenceOOoMajorMinor=4.1
294 // creating the UI stuff is cheap, don't bother only applying it for the flavor...
295 preBuild.dependsOn 'createRCfiles',
296 'createStrippedConfigMain',
297 'createStrippedConfigRegistry',
301 clean.dependsOn 'cleanCopyAssets',
302 'cleanCreateStrippedConfig',
303 'cleanCreateFullConfig'