summaryrefslogtreecommitdiff
path: root/autofill-parser/build.gradle.kts
blob: 7f2a6467e45547248b7c831c065224c0a0ee3928 (about) (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
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
plugins {
  kotlin("android")
  id("maven-publish")
}

// Type safety can sometimes suck
fun getCredential(type: String): String {
    return when (type) {
        // Attempt to find credentials passed by -Pmaven.$type=
        "user", "password" -> (findProperty("maven.$type")
            // Fall back to MAVEN_$type from env
            ?: System.getenv("MAVEN_${type.toUpperCase()}"))?.toString()
            // Finally fallthrough to an empty string to let task configuration complete
            // even if actual publishing is going to fail
            ?: ""
        else -> throw IllegalArgumentException("Invalid credential type: $type")
    }
}

android {
    defaultConfig {
        versionCode = 1
        versionName = "1.0"
        consumerProguardFiles("consumer-rules.pro")
    }
}

afterEvaluate {
    publishing {
        repositories {
            maven {
                name = "aps"
                url = uri("https://maven.msfjarvis.dev/android-password-store/${findProperty("POM_ARTIFACT_ID")}")
                credentials {
                    username = getCredential("user")
                    password = getCredential("password")
                }
            }
        }
        publications {
            create<MavenPublication>("apsMaven") {
                fun getKey(propertyName: String): String {
                    return findProperty(propertyName)?.toString() ?: error("Failed to find property for $propertyName")
                }

                from(components.getByName("release"))
                groupId = getKey("GROUP")
                artifactId = getKey("POM_ARTIFACT_ID")
                version = getKey("VERSION_NAME")
                pom {
                    name.set(getKey("POM_ARTIFACT_ID"))
                    description.set(getKey("POM_ARTIFACT_DESCRIPTION"))
                    url.set(getKey("POM_URL"))
                    licenses {
                        license {
                            name.set(getKey("POM_LICENSE_NAME"))
                            url.set(getKey("POM_LICENSE_URL"))
                        }
                    }
                    developers {
                        developer {
                            id.set(getKey("POM_DEVELOPER_ID"))
                            name.set(getKey("POM_DEVELOPER_NAME"))
                            email.set(getKey("POM_DEVELOPER_EMAIL"))
                        }
                    }
                    scm {
                        connection.set(getKey("POM_SCM_CONNECTION"))
                        developerConnection.set(getKey("POM_SCM_DEV_CONNECTION"))
                        url.set(getKey("POM_SCM_URL"))
                    }
                }
            }
        }
    }
}

dependencies {
    compileOnly(Dependencies.AndroidX.annotation)
    implementation(Dependencies.AndroidX.autofill)
    implementation(Dependencies.Kotlin.Coroutines.android)
    implementation(Dependencies.Kotlin.Coroutines.core)
    implementation(Dependencies.ThirdParty.timberkt)
}