Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / android / source / build.gradle
blobc2d4aeae0e56386d9215041e51923764f537c801
1 apply plugin: 'com.android.application'
2 // buildhost settings - paths and the like
3 apply from: 'liboSettings.gradle'
5 project.ext.set("archivesBaseName", "LibreOfficeViewer")
6 allprojects {
7     repositories {
8         maven {
9             url "https://maven.google.com"
10         }
11         flatDir {
12             dirs "${liboWorkdir}/UnpackedTarball/owncloud_android_lib/build/outputs/aar"
13         }
14     }
16 //build-time dependencies - android plugin for gradle
17 buildscript {
18     repositories {
19         jcenter()
20         maven {
21             url "https://maven.google.com"
22         }
23     }
24     dependencies {
25         classpath 'com.android.tools.build:gradle:3.0.1'
26     }
29 // compile-time dependencies
30 dependencies {
31     implementation fileTree(dir: "${liboInstdir}/${liboUREJavaFolder}", include: [
32             "java_uno.jar",
33             "juh.jar",
34             "jurt.jar",
35             "ridl.jar",
36             "unoloader.jar"
37     ])
38     implementation files("${liboInstdir}/${liboShareJavaFolder}/unoil.jar")
39     debugImplementation(name:'owncloud_android_lib-debug', ext:'aar')
40     releaseImplementation(name:'owncloud_android_lib-release', ext:'aar')
41     implementation 'com.android.support:design:27.0.1' // also pulls-in corresponding support libraries
42     implementation 'com.android.support.constraint:constraint-layout:1.0.2'
45 android {
46     compileSdkVersion 26
47     buildToolsVersion "27.0.1"
48     compileOptions {
49         // silence some java-language features hints
50         sourceCompatibility 6
51     }
52     // uses non-conventional source layout, so need to reconfigure accordingly
53     // ToDo move to conventional layout, so stuff can be stripped down.
54     sourceSets {
55         main.manifest.srcFile 'AndroidManifest.xml'
56         main.assets.srcDirs = ['assets']
57         main.res.srcDirs = ['res']
58         main.java.srcDirs = ['../Bootstrap/src', 'src/java']
59         main.jniLibs.srcDirs = ['jniLibs']
60         main.jni.srcDirs = [] // don't attempt to build native-lib via gradle
61         // the configuration data that might be stripped or not
62         fullUI.assets.srcDirs 'assets_fullUI'
63         strippedUI.assets.srcDirs 'assets_strippedUI'
64     }
65     defaultConfig {
66         minSdkVersion 14
67         targetSdkVersion 24
68         vectorDrawables.useSupportLibrary = true
69     }
70     buildTypes {
71         debug {
72             // make android studio happy...
73             jniDebuggable true
74             // would work just fine with external, but setting emulator up is a little more work
75             manifestPlaceholders = [installLocation: "auto", extractNativeLibs: "false"]
76         }
77         release {
78             // need to extract native libs (allow to compress them in apk), since otherwise would
79             // exceed maximum size for playstore
80             manifestPlaceholders = [installLocation: "preferExternal", extractNativeLibs: "true"]
81         }
82     }
84     flavorDimensions "default"
85     productFlavors {
86         strippedUI.dimension "default"
87         fullUI.dimension "default"
88     }
91 /* remark inherited from makefile:
92 Then "assets". Let the directory structure under assets mimic
93 that under solver for now.
95 Please note that I have no idea what all of this is really necessary and for
96 much of this stuff being copied, no idea whether it makes any sense at all.
97 Much of this is copy-pasted from android/qa/sc/Makefile (where a couple of
98 unit tests for sc are built, and those do seem to mostly work) and
99 android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
100 extent)
101  */
103 // Assets that are unpacked at run-time into the app's data directory. These
104 // are files read by non-LO code, fontconfig and freetype for now, that doesn't
105 // understand "/assets" paths.
106 task copyUnpackAssets(type: Copy) {
107     description "copies assets that need to be extracted on the device"
108     into 'assets/unpack'
109     into('program') {
110         from("${liboInstdir}/${liboEtcFolder}/types") {
111             includes = [
112                     "offapi.rdb",
113                     "oovbaapi.rdb"
114             ]
115         }
116         from("${liboInstdir}/${liboUreMiscFolder}") {
117             includes = ["types.rdb"]
118             rename 'types.rdb', 'udkapi.rdb'
119         }
120     }
121     into('user/fonts') {
122         from "${liboInstdir}/share/fonts/truetype"
123         // Note: restrict list of fonts due to size considerations - no technical reason anymore
124         // ToDo: fonts would be good candidate for using Expansion Files instead
125         includes = [
126                 "Liberation*.ttf",
127                 "Caladea-*.ttf",
128                 "Carlito-*.ttf",
129                 "Gen*.ttf",
130                 "opens___.ttf"
131         ]
132     }
133     into('etc/fonts') {
134         from "./"
135         includes = ['fonts.conf']
136         filter {
137             String line ->
138                 line.replaceAll(
139                         '@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}")
140                 )
141         }
142     }
145 task copyAssets(type: Copy) {
146     description "copies assets that can be accessed within the installed apk"
147     into 'assets'
148     from("${liboSrcRoot}/readlicense_oo/license/") {
149         includes = ["LICENSE", "NOTICE"]
150         rename "LICENSE", "license.txt"
151         rename "NOTICE", "notice.txt"
152     }
153     from("${liboExampleDocument}") {
154         rename ".*", "example.odt"
155     }
156     into('program') {
157         from "${liboInstdir}/program"
158         includes = ['services.rdb', 'services/services.rdb']
160         into('resource') {
161             from "${liboInstdir}/${liboSharedResFolder}"
162             includes = ['*en-US.res']
163         }
164     }
165     into('share') {
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']
171     }
174 task createFullConfig(type: Copy) {
175     // grab dir to clear whole hierarchy on clean target
176     outputs.dir "assets_fullUI"
177     into 'assets_fullUI/share/config/soffice.cfg'
178     from "${liboInstdir}/share/config/soffice.cfg"
181 task createStrippedConfig {
182     def preserveDir = file("assets_strippedUI/share/config/soffice.cfg/empty")
183     outputs.dir "assets_strippedUI"
184     outputs.dir "assets_strippedUI/share/registry/res"
185     outputs.file preserveDir
187     doLast {
188         file('assets_strippedUI/share/registry/res').mkdirs()
189         file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
190         // just empty file
191         preserveDir.text = ""
192     }
196 task createStrippedConfigMain(type: Exec) {
197     dependsOn 'createStrippedConfig'
198     inputs.files "${liboInstdir}/share/registry/main.xcd", "${liboSrcRoot}/android/mobile-config.py"
199     outputs.file "assets_strippedUI/share/registry/main.xcd"
200     executable "${liboSrcRoot}/android/mobile-config.py"
201     args = ["${liboInstdir}/share/registry/main.xcd", "assets_strippedUI/share/registry/main.xcd"]
204 task createStrippedConfigRegistry(type: Exec) {
205     dependsOn 'createStrippedConfig'
206     inputs.files "${liboInstdir}/share/registry/res/registry_en-US.xcd", "${liboSrcRoot}/android/mobile-config.py"
207     outputs.file "assets_strippedUI/share/registry/res/registry_en-US.xcd"
208     executable "${liboSrcRoot}/android/mobile-config.py"
209     args = ["${liboInstdir}/share/registry/res/registry_en-US.xcd", "assets_strippedUI/share/registry/res/registry_en-US.xcd"]
210     doFirst {
211         file('assets_strippedUI/share/registry/res').mkdirs()
212     }
215 task createRCfiles {
216     inputs.file "liboSettings.gradle"
217     dependsOn copyUnpackAssets, copyAssets
218     def sofficerc     = file('assets/unpack/program/sofficerc')
219     def fundamentalrc = file('assets/program/fundamentalrc')
220     def bootstraprc   = file('assets/program/bootstraprc')
221     def unorc         = file('assets/program/unorc')
222     def versionrc     = file('assets/program/versionrc')
224     outputs.files sofficerc, fundamentalrc, unorc, bootstraprc, versionrc
226     doLast {
227         sofficerc.text = '''\
228             [Bootstrap]
229             Logo=1
230             NativeProgress=1
231             URE_BOOTSTRAP=file:///assets/program/fundamentalrc
232             HOME=$APP_DATA_DIR/cache
233             OSL_SOCKET_PATH=$APP_DATA_DIR/cache
234             '''.stripIndent()
236         fundamentalrc.text =  '''\
237             [Bootstrap]
238             LO_LIB_DIR=file://$APP_DATA_DIR/lib/
239             BRAND_BASE_DIR=file:///assets
240             CONFIGURATION_LAYERS=xcsxcu:${BRAND_BASE_DIR}/share/registry res:${BRAND_BASE_DIR}/share/registry
241             URE_BIN_DIR=file:///assets/ure/bin/dir/nothing-here/we-can/exec-anyway
242             '''.stripIndent()
244         bootstraprc.text =  '''\
245             [Bootstrap]
246             InstallMode=<installmode>
247             ProductKey=LibreOffice '''+ "${liboVersionMajor}.${liboVersionMinor}" + '''
248             UserInstallation=file://$APP_DATA_DIR
249             '''.stripIndent()
251         unorc.text = '''\
252             [Bootstrap]
253             URE_INTERNAL_LIB_DIR=file://$APP_DATA_DIR/lib/
254             UNO_TYPES=file://$APP_DATA_DIR/program/udkapi.rdb file://$APP_DATA_DIR/program/offapi.rdb file://$APP_DATA_DIR/program/oovbaapi.rdb
255             UNO_SERVICES=file:///assets/program/services.rdb file:///assets/program/services/services.rdb
256             '''.stripIndent()
258         versionrc.text = '''\
259             [Version]
260             AllLanguages=en-US
261             BuildVersion=
262             buildid=''' + "${liboGitFullCommit}" + '''
263             ReferenceOOoMajorMinor=4.1
264             '''.stripIndent()
265     }
268 // creating the UI stuff is cheap, don't bother only applying it for the flavor..
269 preBuild.dependsOn 'createRCfiles',
270         'createStrippedConfigMain',
271         'createStrippedConfigRegistry',
272         'createFullConfig'
274 clean.dependsOn 'cleanCopyAssets',
275         'cleanCreateStrippedConfig',
276         'cleanCreateFullConfig'