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:7.4.2'
28 // compile-time dependencies
30 implementation fileTree(dir: "${liboInstdir}/${liboUREJavaFolder}", include: [
35 implementation 'com.google.android.material:material:1.8.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 /* 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"
152 // include icons, Impress styles and required .ui files
155 from ("${liboInstdir}/share/config")
156 includes = ['images_**.zip',
157 '**/simpress/**.xml',
159 '**/hfmenubutton.ui',
160 '**/inforeadonlydialog.ui',
161 '**/pbmenubutton.ui',
170 from "${liboInstdir}/program"
171 includes = ['services.rdb', 'services/services.rdb']
174 from "${liboInstdir}/${liboSharedResFolder}"
175 includes = ['*en-US.res']
179 from("${liboInstdir}/share") {
180 // Filter data is needed by e.g. the drawingML preset shape import.
181 includes = ['registry/**', 'filter/**']
182 // those two get processed by mobile-config.py
183 excludes = ['registry/main.xcd', 'registry/res/registry_en-US.xcd']
185 // separate data files for Chinese and Japanese
186 from("${liboWorkdir}/CustomTarget/i18npool/breakiterator/") {
192 task copyAppResources(type: Copy) {
193 description "copies documents to make them available as app resources"
194 into 'res_generated/raw'
195 from("${liboInstdir}") {
196 includes = ["LICENSE", "NOTICE"]
197 rename "LICENSE", "license.txt"
198 rename "NOTICE", "notice.txt"
200 from("${liboExampleDocument}") {
201 rename ".*", "example.odt"
205 task createFullConfig(type: Copy) {
206 // grab dir to clear whole hierarchy on clean target
207 outputs.dir "assets_fullUI"
208 into 'assets_fullUI/share/config/soffice.cfg'
209 from "${liboInstdir}/share/config/soffice.cfg"
212 task createStrippedConfig {
213 def preserveDir = file("assets_strippedUI/share/config/soffice.cfg/empty")
214 outputs.dir "assets_strippedUI"
215 outputs.dir "assets_strippedUI/share/registry/res"
216 outputs.file preserveDir
219 file('assets_strippedUI/share/registry/res').mkdirs()
220 file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
222 preserveDir.text = ""
227 task createStrippedConfigMain(type: Exec) {
228 dependsOn 'createStrippedConfig'
229 inputs.files "${liboInstdir}/share/registry/main.xcd", "${liboSrcRoot}/android/mobile-config.py"
230 outputs.file "assets_strippedUI/share/registry/main.xcd"
231 executable "${liboSrcRoot}/android/mobile-config.py"
232 args = ["${liboInstdir}/share/registry/main.xcd", "assets_strippedUI/share/registry/main.xcd"]
235 task createStrippedConfigRegistry(type: Exec) {
236 dependsOn 'createStrippedConfig'
237 inputs.files "${liboInstdir}/share/registry/res/registry_en-US.xcd", "${liboSrcRoot}/android/mobile-config.py"
238 outputs.file "assets_strippedUI/share/registry/res/registry_en-US.xcd"
239 executable "${liboSrcRoot}/android/mobile-config.py"
240 args = ["${liboInstdir}/share/registry/res/registry_en-US.xcd", "assets_strippedUI/share/registry/res/registry_en-US.xcd"]
242 file('assets_strippedUI/share/registry/res').mkdirs()
247 inputs.file "liboSettings.gradle"
248 dependsOn copyUnpackAssets, copyAssets
249 def sofficerc = file('assets/unpack/program/sofficerc')
250 def fundamentalrc = file('assets/program/fundamentalrc')
251 def bootstraprc = file('assets/program/bootstraprc')
252 def unorc = file('assets/program/unorc')
253 def versionrc = file('assets/program/versionrc')
255 outputs.files sofficerc, fundamentalrc, unorc, bootstraprc, versionrc
258 sofficerc.text = '''\
262 URE_BOOTSTRAP=file:///assets/program/fundamentalrc
263 HOME=$APP_DATA_DIR/cache
264 OSL_SOCKET_PATH=$APP_DATA_DIR/cache
267 fundamentalrc.text = '''\
269 LO_LIB_DIR=file://$APP_DATA_DIR/lib/
270 BRAND_BASE_DIR=file:///assets
271 BRAND_SHARE_SUBDIR=share
272 CONFIGURATION_LAYERS=xcsxcu:${BRAND_BASE_DIR}/share/registry res:${BRAND_BASE_DIR}/share/registry
273 URE_BIN_DIR=file:///assets/ure/bin/dir/nothing-here/we-can/exec-anyway
276 bootstraprc.text = '''\
278 InstallMode=<installmode>
279 ProductKey=LibreOffice '''+ "${liboVersionMajor}.${liboVersionMinor}" + '''
280 UserInstallation=file://$APP_DATA_DIR
285 URE_INTERNAL_LIB_DIR=file://$APP_DATA_DIR/lib/
286 UNO_TYPES=file://$APP_DATA_DIR/program/udkapi.rdb file://$APP_DATA_DIR/program/offapi.rdb file://$APP_DATA_DIR/program/oovbaapi.rdb
287 UNO_SERVICES=file:///assets/program/services.rdb file:///assets/program/services/services.rdb
290 versionrc.text = '''\
293 buildid=''' + "${liboGitFullCommit}" + '''
294 ReferenceOOoMajorMinor=4.1
299 // creating the UI stuff is cheap, don't bother only applying it for the flavor...
300 preBuild.dependsOn 'createRCfiles',
301 'createStrippedConfigMain',
302 'createStrippedConfigRegistry',
306 clean.dependsOn 'cleanCopyAssets',
307 'cleanCreateStrippedConfig',
308 'cleanCreateFullConfig'