build.gradle 5.99 KB
Newer Older
Jeff Boek's avatar
Jeff Boek committed
1
2
3
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
4
    // This logic is duplicated in the allprojects block: I don't know how to fix that.
Jeff Boek's avatar
Jeff Boek committed
5
    repositories {
6
        maven {
7
            name "Mozilla Nightly"
8
9
10
11
12
13
14
            url "https://nightly.maven.mozilla.org/maven2"
            content {
                // Improve performance: only check moz maven for mozilla deps.
                includeGroupByRegex RepoMatching.mozilla
            }
        }
        maven {
15
            name "Mozilla"
16
17
18
19
20
21
            url "https://maven.mozilla.org/maven2"
            content {
                // Improve performance: only check moz maven for mozilla deps.
                includeGroupByRegex RepoMatching.mozilla
            }
        }
22
23
24
25
26
27
28
29
30
31
32
33
34
35
        if (project.hasProperty("googleRepo")) {
            maven {
                name "Google"
                url project.property("googleRepo")
            }
        } else {
            google() {
                content {
                    // Improve performance: only check google maven for mozilla deps.
                    includeGroupByRegex RepoMatching.androidx
                    includeGroupByRegex RepoMatching.comGoogleAndroid
                    includeGroupByRegex RepoMatching.comGoogleFirebase
                    includeGroupByRegex RepoMatching.comAndroid
                }
36
37
            }
        }
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

        if (project.hasProperty("jcenterRepo")) {
            maven {
                name "BintrayJCenter"
                url project.property("jcenterRepo")
            }
        } else {
            jcenter() {
                content {
                    // Improve security: don't search deps with known repos.
                    excludeGroupByRegex RepoMatching.mozilla
                    excludeGroupByRegex RepoMatching.androidx
                    excludeGroupByRegex RepoMatching.comGoogleAndroid
                    excludeGroupByRegex RepoMatching.comGoogleFirebase
                    excludeGroupByRegex RepoMatching.comAndroid
                }
54
55
            }
        }
Jeff Boek's avatar
Jeff Boek committed
56
    }
57

Jeff Boek's avatar
Jeff Boek committed
58
    dependencies {
59
60
        classpath Deps.tools_androidgradle
        classpath Deps.tools_kotlingradle
61
        classpath Deps.androidx_safeargs
62
        classpath Deps.allopen
63
        classpath Deps.osslicenses_plugin
Jeff Boek's avatar
Jeff Boek committed
64

65
66
        classpath "org.mozilla.components:tooling-glean-gradle:${Versions.mozilla_android_components}"

Jeff Boek's avatar
Jeff Boek committed
67
68
69
70
71
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

72
plugins {
Emily Kager's avatar
Emily Kager committed
73
    id("io.gitlab.arturbosch.detekt").version("1.6.0")
74
75
}

Jeff Boek's avatar
Jeff Boek committed
76
allprojects {
77
    // This logic is duplicated in the buildscript block: I don't know how to fix that.
Jeff Boek's avatar
Jeff Boek committed
78
    repositories {
79
        maven {
80
            name "Mozilla Nightly"
81
            url "https://nightly.maven.mozilla.org/maven2"
82
83
84
85
            content {
                // Improve performance: only check moz maven for mozilla deps.
                includeGroupByRegex RepoMatching.mozilla
            }
86
        }
87
        maven {
88
            name "Mozilla"
89
            url "https://maven.mozilla.org/maven2"
90
91
92
93
            content {
                // Improve performance: only check moz maven for mozilla deps.
                includeGroupByRegex RepoMatching.mozilla
            }
94
        }
95
96
97
98
99
100
101
102
103
104
105
106
107
108
        if (project.hasProperty("googleRepo")) {
            maven {
                name "Google"
                url project.property("googleRepo")
            }
        } else {
            google() {
                content {
                    // Improve performance: only check google maven for mozilla deps.
                    includeGroupByRegex RepoMatching.androidx
                    includeGroupByRegex RepoMatching.comGoogleAndroid
                    includeGroupByRegex RepoMatching.comGoogleFirebase
                    includeGroupByRegex RepoMatching.comAndroid
                }
109
110
            }
        }
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
        if (project.hasProperty("jcenterRepo")) {
            maven {
                name "BintrayJCenter"
                url project.property("jcenterRepo")
            }
        } else {
            jcenter() {
                content {
                    // Improve security: don't search deps with known repos.
                    excludeGroupByRegex RepoMatching.mozilla
                    excludeGroupByRegex RepoMatching.androidx
                    excludeGroupByRegex RepoMatching.comGoogleAndroid
                    excludeGroupByRegex RepoMatching.comGoogleFirebase
                    excludeGroupByRegex RepoMatching.comAndroid
                }
126
            }
Jeff Boek's avatar
Jeff Boek committed
127
        }
Jeff Boek's avatar
Jeff Boek committed
128
    }
129

130
    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
131
        kotlinOptions.jvmTarget = "1.8"
132
133
134
        kotlinOptions.allWarningsAsErrors = true
        kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental", "-Xskip-runtime-version-check"]
    }
Jeff Boek's avatar
Jeff Boek committed
135
136
137
138
}

task clean(type: Delete) {
    delete rootProject.buildDir
139
}
140
141
142

detekt {
    // The version number is duplicated, please refer to plugins block for more details
Emily Kager's avatar
Emily Kager committed
143
    version = "1.6.0"
144
    input = files("$projectDir/app/src")
145
146
147
148
149
150
151
    config = files("$projectDir/config/detekt.yml")

    reports {
        html {
            enabled = true
            destination = file("$projectDir/build/reports/detekt.html")
        }
152
153
154
        xml {
            enabled = false
        }
155
156
157
158
159
160
161
162
    }
}

configurations {
    ktlint
}

dependencies {
163
    ktlint "com.pinterest:ktlint:0.34.2"
164
165
    detekt project(":mozilla-detekt-rules")
    detekt "io.gitlab.arturbosch.detekt:detekt-cli:${Versions.detekt}"
166
167
168
169
170
}

task ktlint(type: JavaExec, group: "verification") {
    description = "Check Kotlin code style."
    classpath = configurations.ktlint
171
    main = "com.pinterest.ktlint.Main"
172
    args "app/src/**/*.kt"
173
}
Emily Kager's avatar
Emily Kager committed
174
175
176
177
178
179

tasks.withType(io.gitlab.arturbosch.detekt.Detekt.class) {
    exclude("**/resources/**")
    exclude("**/test/**")
    exclude("**/tmp/**")
}
180
181
182
183
184
185
186

task listRepositories {
    doLast {
        println "Repositories:"
        project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
   }
}