1 apply plugin: 'com.android.application'
2 // buildhost settings - paths and the like
3 apply from: 'liboSettings.gradle'
9 url "https://ipv6.repo1.maven.org/maven2"
14 //build-time dependencies - android plugin for gradle
19 url "https://ipv6.repo1.maven.org/maven2"
24 classpath 'com.android.tools.build:gradle:8.2.0'
28 // compile-time dependencies
30 implementation fileTree(dir: "${liboInstdir}/${liboUREJavaFolder}", include: [
35 implementation 'com.google.android.material:material:1.10.0'
36 implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
37 implementation "androidx.multidex:multidex:2.0.1"
41 namespace 'org.libreoffice'
43 // uses non-conventional source layout, so need to reconfigure accordingly
44 // ToDo move to conventional layout, so stuff can be stripped down.
46 main.manifest.srcFile 'AndroidManifest.xml'
47 main.assets.srcDirs = ['assets']
48 main.res.srcDirs = ['res', 'res_generated']
49 main.java.srcDirs = ['../Bootstrap/src', 'src/java']
50 main.jniLibs.srcDirs = ["${liboJniLibsdir}"]
51 // the configuration data that might be stripped or not
52 fullUI.assets.srcDirs 'assets_fullUI'
53 strippedUI.assets.srcDirs 'assets_strippedUI'
54 strippedUIEditing.assets.srcDirs 'assets_strippedUI'
57 // minSdkVersion is set in liboSettings.gradle
59 // multidex needed when > 65,536 methods referenced with minSdKVersion < 21
60 // s. https://developer.android.com/studio/build/multidex
62 vectorDrawables.useSupportLibrary = true
66 // make android studio happy...
68 // would work just fine with external, but setting emulator up is a little more work
69 manifestPlaceholders = [installLocation: "auto"]
72 manifestPlaceholders = [installLocation: "preferExternal"]
76 flavorDimensions "default"
80 buildConfigField 'boolean', 'ALLOW_EDITING', 'false'
84 buildConfigField 'boolean', 'ALLOW_EDITING', 'true'
86 fullUI.dimension "default"
89 // don't error-out on missing translations
90 warning 'MissingTranslation'
94 // show warnings about use of deprecated API
95 tasks.withType(JavaCompile).configureEach {
96 options.deprecation = true
99 /* remark inherited from makefile:
100 Then "assets". Let the directory structure under assets mimic
101 that under solver for now.
103 Please note that I have no idea what all of this is really necessary and for
104 much of this stuff being copied, no idea whether it makes any sense at all.
105 Much of this is copy-pasted from android/qa/sc/Makefile (where a couple of
106 unit tests for sc are built, and those do seem to mostly work) and
107 android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
111 // Assets that are unpacked at run-time into the app's data directory. These
112 // are files read by non-LO code, fontconfig and freetype for now, that doesn't
113 // understand "/assets" paths.
114 task copyUnpackAssets(type: Copy) {
115 description "copies assets that need to be extracted on the device"
118 from("${liboInstdir}/${liboEtcFolder}/types") {
124 from("${liboInstdir}/${liboUreMiscFolder}") {
125 includes = ["types.rdb"]
126 rename 'types.rdb', 'udkapi.rdb'
130 from "${liboInstdir}/share/fonts/truetype"
131 // Note: restrict list of fonts due to size considerations - no technical reason anymore
132 // ToDo: fonts would be good candidate for using Expansion Files instead
143 includes = ['fonts.conf']
147 '@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}")
153 task copyAssets(type: Copy) {
154 description "copies assets that can be accessed within the installed apk"
157 // include icons, Impress styles and required .ui files
160 from ("${liboInstdir}/share/config")
161 includes = ['images_**.zip',
162 '**/simpress/**.xml',
164 '**/hfmenubutton.ui',
165 '**/inforeadonlydialog.ui',
166 '**/pbmenubutton.ui',
175 from "${liboInstdir}/program"
176 includes = ['services.rdb', 'services/services.rdb']
179 from "${liboInstdir}/${liboSharedResFolder}"
180 includes = ['*en-US.res']
184 from("${liboInstdir}/share") {
185 // Filter data is needed by e.g. the drawingML preset shape import.
186 includes = ['registry/**', 'filter/**']
187 // those two get processed by mobile-config.py
188 excludes = ['registry/main.xcd', 'registry/res/registry_en-US.xcd']
190 // separate data files for Chinese and Japanese
191 from("${liboWorkdir}/CustomTarget/i18npool/breakiterator/") {
197 task copyAppResources(type: Copy) {
198 description "copies documents to make them available as app resources"
199 into 'res_generated/raw'
200 from("${liboInstdir}") {
201 includes = ["LICENSE", "NOTICE"]
202 rename "LICENSE", "license.txt"
203 rename "NOTICE", "notice.txt"
207 task createFullConfig(type: Copy) {
208 // grab dir to clear whole hierarchy on clean target
209 outputs.dir "assets_fullUI"
210 into 'assets_fullUI/share/config/soffice.cfg'
211 from "${liboInstdir}/share/config/soffice.cfg"
214 task createStrippedConfig {
215 def preserveDir = file("assets_strippedUI/share/config/soffice.cfg/empty")
216 outputs.dir "assets_strippedUI"
217 outputs.dir "assets_strippedUI/share/registry/res"
218 outputs.file preserveDir
221 file('assets_strippedUI/share/registry/res').mkdirs()
222 file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
224 preserveDir.text = ""
229 task createStrippedConfigMain(type: Exec) {
230 dependsOn 'createStrippedConfig'
231 inputs.files "${liboInstdir}/share/registry/main.xcd", "${liboSrcRoot}/android/mobile-config.py"
232 outputs.file "assets_strippedUI/share/registry/main.xcd"
233 executable "${liboSrcRoot}/android/mobile-config.py"
234 args = ["${liboInstdir}/share/registry/main.xcd", "assets_strippedUI/share/registry/main.xcd"]
237 task createStrippedConfigRegistry(type: Exec) {
238 dependsOn 'createStrippedConfig'
239 inputs.files "${liboInstdir}/share/registry/res/registry_en-US.xcd", "${liboSrcRoot}/android/mobile-config.py"
240 outputs.file "assets_strippedUI/share/registry/res/registry_en-US.xcd"
241 executable "${liboSrcRoot}/android/mobile-config.py"
242 args = ["${liboInstdir}/share/registry/res/registry_en-US.xcd", "assets_strippedUI/share/registry/res/registry_en-US.xcd"]
244 file('assets_strippedUI/share/registry/res').mkdirs()
249 inputs.file "liboSettings.gradle"
250 dependsOn copyUnpackAssets, copyAssets
251 def sofficerc = file('assets/unpack/program/sofficerc')
252 def fundamentalrc = file('assets/program/fundamentalrc')
253 def bootstraprc = file('assets/program/bootstraprc')
254 def unorc = file('assets/program/unorc')
255 def versionrc = file('assets/program/versionrc')
257 outputs.files sofficerc, fundamentalrc, unorc, bootstraprc, versionrc
260 sofficerc.text = '''\
264 URE_BOOTSTRAP=file:///assets/program/fundamentalrc
265 HOME=$APP_DATA_DIR/cache
266 OSL_SOCKET_PATH=$APP_DATA_DIR/cache
269 fundamentalrc.text = '''\
271 LO_LIB_DIR=file://$APP_DATA_DIR/lib/
272 BRAND_BASE_DIR=file:///assets
273 BRAND_SHARE_SUBDIR=share
274 CONFIGURATION_LAYERS=xcsxcu:${BRAND_BASE_DIR}/share/registry res:${BRAND_BASE_DIR}/share/registry
275 URE_BIN_DIR=file:///assets/ure/bin/dir/nothing-here/we-can/exec-anyway
278 bootstraprc.text = '''\
280 InstallMode=<installmode>
281 ProductKey=LibreOffice '''+ "${liboVersionMajor}.${liboVersionMinor}" + '''
282 UserInstallation=file://$APP_DATA_DIR
287 URE_INTERNAL_LIB_DIR=file://$APP_DATA_DIR/lib/
288 UNO_TYPES=file://$APP_DATA_DIR/program/udkapi.rdb file://$APP_DATA_DIR/program/offapi.rdb file://$APP_DATA_DIR/program/oovbaapi.rdb
289 UNO_SERVICES=file:///assets/program/services.rdb file:///assets/program/services/services.rdb
292 versionrc.text = '''\
295 buildid=''' + "${liboGitFullCommit}" + '''
296 ReferenceOOoMajorMinor=4.1
301 // creating the UI stuff is cheap, don't bother only applying it for the flavor...
302 preBuild.dependsOn 'createRCfiles',
303 'createStrippedConfigMain',
304 'createStrippedConfigRegistry',
308 clean.dependsOn 'cleanCopyAssets',
309 'cleanCreateStrippedConfig',
310 'cleanCreateFullConfig'