aboutsummaryrefslogtreecommitdiff
path: root/gradle/fdroid_yaml_output.gradle
blob: a2ccbad004e97fbc62332ee93e10ddbdfce77025 (plain)
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
def generateFdroidYamls = project.tasks.register('generateFdroidYamls') { task ->
    task.description = 'Generates a file with the YAML entry for publishing an APK fo a file'
    task.group = 'publish'
    doLast {
        //must create this folder. So out CI upload-artifacts will not fail on non-existing folder
        rootProject.file('outputs/fdroid').mkdirs()
        task.dependsOn.forEach { Task dependedTask ->
            def taskProject = dependedTask.project
            File outputYamlFile = rootProject.file("outputs/fdroid/${taskProject.android.defaultConfig.applicationId}.yaml")
            outputYamlFile.write("")
            println("Will write fdroid data to ${outputYamlFile.absolutePath}")
            def commit = 'git rev-parse HEAD'.execute().text.trim()

            def lines = new ArrayList<String>()
            lines.add("  - versionName: ${taskProject.android.defaultConfig.versionName}")
            lines.add("    versionCode: ${taskProject.android.defaultConfig.versionCode}")
            lines.add("    commit: ${commit}")
            lines.add("    gradle:")
            lines.add("      - yes")
            lines.add("    output: outputs/apks/release/${taskProject.path.substring(1).replace(':', '-')}-${taskProject.android.defaultConfig.versionCode}.apk")
            if (taskProject.path.contains('ime:app')) {
                lines.add("    ndk: r14b")
            }
            lines.add("    gradleprops:")
            lines.add("      - forceVersionBuildCount=${System.getenv('BUILD_COUNT_FOR_VERSION')}")
            lines.add("")
            lines.add("AutoUpdateMode: None")
            lines.add("UpdateCheckMode: RepoManifest")
            lines.add("CurrentVersion: ${taskProject.android.defaultConfig.versionName}")
            lines.add("CurrentVersionCode: ${taskProject.android.defaultConfig.versionCode}")

            lines.forEach { line ->
                outputYamlFile.append(line)
                outputYamlFile.append('\n')
            }
        }
    }
}

subprojects {
    tasks.configureEach { newTask ->
        if (newTask.name == 'assembleRelease') {
            if (newTask.project.plugins.hasPlugin('com.android.application')) {
                generateFdroidYamls.configure {
                    dependsOn newTask
                }
            }
        }
    }
}