File: build.gradle

package info (click to toggle)
mediainfo 26.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,912 kB
  • sloc: cpp: 19,090; objc: 3,102; xml: 1,428; sh: 1,328; python: 263; makefile: 212
file content (215 lines) | stat: -rw-r--r-- 7,764 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
apply plugin: 'com.android.application'
apply plugin: 'com.google.devtools.ksp'
apply plugin: 'kotlin-android'

import groovy.xml.XmlParser
import groovy.xml.XmlUtil
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

android {
    buildFeatures {
        viewBinding = true
    }
    compileSdk = 36
    namespace = "net.mediaarea.mediainfo"
    defaultConfig {
        applicationId "net.mediaarea.mediainfo"
        multiDexEnabled = true
        minSdkVersion 21
        versionCode 57
        versionName "26.01"
        targetSdkVersion 36
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary = true
        }
        externalNativeBuild {
            cmake {
                cppFlags "-DUNICODE -D_UNICODE -DMEDIAINFO_ADVANCED_NO -DMEDIAINFO_REFERENCES_NO -DMEDIAINFO_FILTER_NO -DMEDIAINFO_DUPLICATE_NO -DMEDIAINFO_MACROBLOCKS_NO -DMEDIAINFO_TRACE_NO -DMEDIAINFO_TRACE_FFV1CONTENT_NO -DMEDIAINFO_IBI_NO -DMEDIAINFO_DIRECTORY_NO -DMEDIAINFO_LIBCURL_NO -DMEDIAINFO_LIBMMS_NO -DMEDIAINFO_DVDIF_ANALYZE_NO -DMEDIAINFO_MPEGTS_DUPLICATE_NO -DMEDIAINFO_READTHREAD_NO -DMEDIAINFO_MD5_NO -DMEDIAINFO_SHA1_NO -DMEDIAINFO_SHA2_NO -DMEDIAINFO_EVENTS_NO -DMEDIAINFO_DEMUX_NO -DMEDIAINFO_AES_NO -DMEDIAINFO_FIXITY_NO -DMEDIAINFO_READER_NO -DMEDIAINFO_NEXTPACKET_NO"
                arguments "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
            }
        }
        splits {
            abi {
                reset()
                include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
            }
        }
        if(project.hasProperty("RELEASE_STORE_FILE")) {
            signingConfigs {
                release {
                    storeFile file(RELEASE_STORE_FILE)
                    storePassword RELEASE_STORE_PASSWORD
                    keyAlias RELEASE_KEY_ALIAS
                    keyPassword RELEASE_KEY_PASSWORD
                }
            }
        }
    }
    buildTypes {
        release {
            if(project.hasProperty("RELEASE_STORE_FILE")) {
                signingConfig signingConfigs.release
            }
            minifyEnabled true
            shrinkResources = true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    splits {
        abi {
            def isBuildingBundle = gradle.startParameter.taskNames.any { it.toLowerCase().contains('bundle') }
            enable = !isBuildingBundle

            universalApk = true
        }
    }
    bundle {
        language {
            enableSplit = false
        }
    }
    compileOptions {
        targetCompatibility JavaVersion.VERSION_21
        sourceCompatibility JavaVersion.VERSION_21
    }
    kotlin {
        compilerOptions {
            jvmTarget = JvmTarget.JVM_21
        }
    }
    def abiCodes = ['armeabi-v7a':1, 'arm64-v8a':2, 'x86':3, 'x86_64':4]
    android.applicationVariants.configureEach { variant ->
        // Assigns a different version code for each output APK.
        variant.outputs.each {
            output ->
                def abiName = output.getFilter('ABI')
                output.versionCodeOverride = variant.versionCode * 10 + abiCodes.get(abiName, 0)
        }
    }
}

tasks.register('copyLocales', DefaultTask) {
    def locales = [:]

    fileTree("../../../../Source/Resource/Plugin/Language").visit { FileVisitDetails details ->
        def locale = details.file.name.replace(".csv", "").replace("-", "-r")
        if (locale == "gr") {
            locale = "el"
        }

        // copy localized csv into raw resources
        def raw = "src/main/res/raw-" + locale

        if (details.file.name == "en.csv") {
            raw = "src/main/res/raw"
        }

        mkdir raw
        copy {
            from details.file
            into raw
            rename { "lang.csv" }
        }

        //  update translations xml
        def csv = [:]
        file(details.file).splitEachLine(";") {
            if(it.size()==2 && it[0].size() && it[1].size()) {
                csv[it[0]] = it[1]
            }
        }
        def xml = new XmlParser().parse(file("src/main/res/values/strings.xml"))
        xml.string.each {
            if (it.@translatable == "false" || it.@csv == null || !csv.containsKey(it.@csv)) {
                xml.remove(it)
            }
            else {
                it.value = csv[it.@csv].replaceAll("\\\\r", "").replaceAll("'", "\\\\'").replaceAll("\"", "\\\\\"")
            }
        }

        if (xml.children().size()) {
            def values = "src/main/res/values-" + locale
            mkdir values

            def writer = file(values + "/strings.xml").newPrintWriter("UTF-8") // PrintWriter truncates file before write
            new XmlUtil().serialize(xml, writer)
            writer.close()
            //add locale to list
            locales[csv["  Language_Name"]] = locale
        }
    }

    // update translations list
    def xml = new XmlParser().parse(file("src/main/res/values/arrays.xml"))
    def locales_array = xml.find { it."@name" == "locales" }
    def locales_values_array = xml.find { it."@name" == "locales_values" }

    locales_array.item.each {
        if (locales_array.children().indexOf(it) > 0) {
            locales_array.remove(it)
        }
    }

    locales_values_array.item.each {
        if (locales_values_array.children().indexOf(it) > 0) {
            locales_values_array.remove(it)
        }
    }

    locales.sort().each { lang ->
        def name = new NodeBuilder().item(lang.key)
        locales_array.append(name)

        def value = new NodeBuilder().item(lang.value)
        locales_values_array.append(value)
    }

    def writer = file("src/main/res/values/arrays.xml").newPrintWriter("UTF-8") // PrintWriter truncates file before write
    new XmlUtil().serialize(xml, writer)
    writer.close()
}

preBuild.dependsOn copyLocales

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.google.android.material:material:1.13.0'
    implementation 'androidx.appcompat:appcompat:1.7.1'
    implementation 'androidx.preference:preference-ktx:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.4.0'
    implementation 'com.android.support:design:34.2.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test:runner:1.7.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
    // Android Room
    // can only upgrade when minSdkVersion >= 23
    implementation 'androidx.room:room-runtime:2.7.2'
    implementation 'androidx.room:room-rxjava2:2.7.2'
    ksp 'androidx.room:room-compiler:2.7.2'
    //RxJava
    implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    // Android Lifecycle
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    ksp "androidx.lifecycle:lifecycle-common-java8:2.10.0"
    // Google Billing
    // can only upgrade when minSdkVersion >= 23
    implementation "com.android.billingclient:billing:8.0.0"
    implementation "com.android.billingclient:billing-ktx:8.0.0"
    // KotlinX Coroutines
    api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2"
    api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.10.2"
    // Locales manager
    implementation 'com.github.YarikSOffice:lingver:1.3.0'
}