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.6.1'
28 // compile-time dependencies
30 implementation fileTree(dir: "${liboInstdir}/${liboUREJavaFolder}", include: [
35 implementation 'com.google.android.material:material:1.12.0'
36 implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
37 implementation 'androidx.preference:preference:1.2.1'
41 archivesName = "LibreOfficeViewer"
45 namespace 'org.libreoffice'
50 // uses non-conventional source layout, so need to reconfigure accordingly
51 // ToDo move to conventional layout, so stuff can be stripped down.
53 main.manifest.srcFile 'AndroidManifest.xml'
54 main.assets.srcDirs = ['assets']
55 main.res.srcDirs = ['res', 'res_generated']
56 main.java.srcDirs = ['../Bootstrap/src', 'src/java']
57 main.jniLibs.srcDirs = ["${liboJniLibsdir}"]
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'
64 // minSdkVersion is set in liboSettings.gradle
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"]
76 manifestPlaceholders = [installLocation: "preferExternal"]
80 flavorDimensions "default"
84 buildConfigField 'boolean', 'ALLOW_EDITING', 'false'
88 buildConfigField 'boolean', 'ALLOW_EDITING', 'true'
90 fullUI.dimension "default"
94 // ignore missing or extra translations, since these are tracked/managed via Weblate
95 ignore 'ExtraTranslation', 'MissingTranslation'
96 // don't error-out on external updates (new gradle plugin, library versions
97 // or target API become available)
98 // don't error-out on TypographyEllipsis, since this can be introduced with
99 // new translations, and those are handled in Weblate
100 informational 'AndroidGradlePluginVersion', 'GradleDependency', 'NewerVersionAvailable', 'OldTargetApi', 'TypographyEllipsis'
101 // don't fail on pre-existing issues
102 // These should be dealt with at some point, though.
103 // To update lint-baseline.xml, just remove the file and run the build again.
104 baseline file("lint-baseline.xml")
105 // s.a. lint.xml that contains further config
109 // show warnings about use of deprecated API
110 tasks.withType(JavaCompile).configureEach {
111 options.deprecation = true
114 /* remark inherited from makefile:
115 Then "assets". Let the directory structure under assets mimic
116 that under solver for now.
118 Please note that I have no idea what all of this is really necessary and for
119 much of this stuff being copied, no idea whether it makes any sense at all.
120 Much of this is copy-pasted from android/qa/sc/Makefile (where a couple of
121 unit tests for sc are built, and those do seem to mostly work) and
122 android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
126 // Assets that are unpacked at run-time into the app's data directory. These
127 // are files read by non-LO code, fontconfig and freetype for now, that doesn't
128 // understand "/assets" paths.
129 task copyUnpackAssets(type: Copy) {
130 description "copies assets that need to be extracted on the device"
133 from("${liboInstdir}/${liboEtcFolder}/types") {
139 from("${liboInstdir}/${liboUreMiscFolder}") {
140 includes = ["types.rdb"]
141 rename 'types.rdb', 'udkapi.rdb'
145 from "${liboInstdir}/share/fonts/truetype"
146 // Note: restrict list of fonts due to size considerations - no technical reason anymore
147 // ToDo: fonts would be good candidate for using Expansion Files instead
158 includes = ['fonts.conf']
162 '@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}")
168 task copyAssets(type: Copy) {
169 description "copies assets that can be accessed within the installed apk"
172 // include icons, Impress styles and required .ui files
175 from ("${liboInstdir}/share/config")
176 includes = ['images_**.zip',
177 '**/simpress/**.xml',
179 '**/hfmenubutton.ui',
180 '**/inforeadonlydialog.ui',
181 '**/pbmenubutton.ui',
190 from "${liboInstdir}/program"
191 includes = ['services.rdb', 'services/services.rdb']
194 from "${liboInstdir}/${liboSharedResFolder}"
195 includes = ['*en-US.res']
199 from("${liboInstdir}/share") {
200 // Filter data is needed by e.g. the drawingML preset shape import.
201 includes = ['registry/**', 'filter/**']
202 // those two get processed by mobile-config.py
203 excludes = ['registry/main.xcd', 'registry/res/registry_en-US.xcd']
205 // separate data files for Chinese and Japanese
206 from("${liboWorkdir}/CustomTarget/i18npool/breakiterator/") {
212 task copyAppResources(type: Copy) {
213 description "copies documents to make them available as app resources"
214 into 'res_generated/raw'
215 from("${liboInstdir}") {
216 includes = ["LICENSE", "NOTICE"]
217 rename "LICENSE", "license.txt"
218 rename "NOTICE", "notice.txt"
222 task createFullConfig(type: Copy) {
223 // grab dir to clear whole hierarchy on clean target
224 outputs.dir "assets_fullUI"
225 into 'assets_fullUI/share/config/soffice.cfg'
226 from "${liboInstdir}/share/config/soffice.cfg"
229 task createStrippedConfig {
230 def preserveDir = file("assets_strippedUI/share/config/soffice.cfg/empty")
231 outputs.dir "assets_strippedUI"
232 outputs.dir "assets_strippedUI/share/registry/res"
233 outputs.file preserveDir
236 file('assets_strippedUI/share/registry/res').mkdirs()
237 file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
239 preserveDir.text = ""
244 task createStrippedConfigMain(type: Exec) {
245 dependsOn 'createStrippedConfig'
246 inputs.files "${liboInstdir}/share/registry/main.xcd", "${liboSrcRoot}/android/mobile-config.py"
247 outputs.file "assets_strippedUI/share/registry/main.xcd"
248 executable "${liboSrcRoot}/android/mobile-config.py"
249 args = ["${liboInstdir}/share/registry/main.xcd", "assets_strippedUI/share/registry/main.xcd"]
252 task createStrippedConfigRegistry(type: Exec) {
253 dependsOn 'createStrippedConfig'
254 inputs.files "${liboInstdir}/share/registry/res/registry_en-US.xcd", "${liboSrcRoot}/android/mobile-config.py"
255 outputs.file "assets_strippedUI/share/registry/res/registry_en-US.xcd"
256 executable "${liboSrcRoot}/android/mobile-config.py"
257 args = ["${liboInstdir}/share/registry/res/registry_en-US.xcd", "assets_strippedUI/share/registry/res/registry_en-US.xcd"]
259 file('assets_strippedUI/share/registry/res').mkdirs()
264 inputs.file "liboSettings.gradle"
265 dependsOn copyUnpackAssets, copyAssets
266 def sofficerc = file('assets/unpack/program/sofficerc')
267 def fundamentalrc = file('assets/program/fundamentalrc')
268 def bootstraprc = file('assets/program/bootstraprc')
269 def unorc = file('assets/program/unorc')
270 def versionrc = file('assets/program/versionrc')
272 outputs.files sofficerc, fundamentalrc, unorc, bootstraprc, versionrc
275 sofficerc.text = '''\
279 URE_BOOTSTRAP=file:///assets/program/fundamentalrc
280 HOME=$APP_DATA_DIR/cache
281 OSL_SOCKET_PATH=$APP_DATA_DIR/cache
284 fundamentalrc.text = '''\
286 LO_LIB_DIR=file://$APP_DATA_DIR/lib/
287 BRAND_BASE_DIR=file:///assets
288 BRAND_SHARE_SUBDIR=share
289 CONFIGURATION_LAYERS=xcsxcu:${BRAND_BASE_DIR}/share/registry res:${BRAND_BASE_DIR}/share/registry
290 URE_BIN_DIR=file:///assets/ure/bin/dir/nothing-here/we-can/exec-anyway
293 bootstraprc.text = '''\
295 InstallMode=<installmode>
296 ProductKey=LibreOffice '''+ "${liboVersionMajor}.${liboVersionMinor}" + '''
297 UserInstallation=file://$APP_DATA_DIR
302 URE_INTERNAL_LIB_DIR=file://$APP_DATA_DIR/lib/
303 UNO_TYPES=file://$APP_DATA_DIR/program/udkapi.rdb file://$APP_DATA_DIR/program/offapi.rdb file://$APP_DATA_DIR/program/oovbaapi.rdb
304 UNO_SERVICES=file:///assets/program/services.rdb file:///assets/program/services/services.rdb
307 versionrc.text = '''\
310 buildid=''' + "${liboGitFullCommit}" + '''
311 ReferenceOOoMajorMinor=4.1
316 // creating the UI stuff is cheap, don't bother only applying it for the flavor...
317 preBuild.dependsOn 'createRCfiles',
318 'createStrippedConfigMain',
319 'createStrippedConfigRegistry',
323 clean.dependsOn 'cleanCopyAssets',
324 'cleanCreateStrippedConfig',
325 'cleanCreateFullConfig'