-
Notifications
You must be signed in to change notification settings - Fork 317
/
build.gradle
165 lines (141 loc) · 5.08 KB
/
build.gradle
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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import org.mozilla.focus.gradle.tasks.GithubDetailsTask
buildscript {
repositories {
google()
mavenCentral()
maven {
// We will always need this repository for retrieving stable dependencies (like Glean).
url "https://maven.mozilla.org/maven2"
}
maven {
url "https://nightly.maven.mozilla.org/maven2"
}
}
dependencies {
classpath FocusDependencies.android_gradle_plugin
classpath FocusDependencies.kotlin_gradle_plugin
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
// NOTE: The Nimbus plugin needs to be refactored into a top-level plugin
// and consumed via includeBuild (using composite builds). This is a short-term
// workaround to consume the latest version of the Nimbus plugin matching the Focus version.
if (Config.readVersionFromFile().contains("a")) {
// Use the latest version of the plugin on the main branch (nightly).
classpath("org.mozilla.components:tooling-nimbus-gradle:latest.release")
} else {
// Use the latest version matching the major version of the branch (beta/release).
classpath("org.mozilla.components:tooling-nimbus-gradle") {
version {
strictly("${Config.majorVersion()}.+")
}
}
}
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "io.gitlab.arturbosch.detekt" version "1.22.0" // Variables in plugins {} aren't supported
}
detekt {
input = files("$projectDir/app")
config = files("$projectDir/quality/detekt.yml")
baseline = file("$projectDir/quality/detekt-baseline.xml")
reports {
html {
enabled = true
destination = file("$projectDir/build/reports/detekt.html")
}
xml {
enabled = false
}
txt {
enabled = false
}
}
}
tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach() {
autoCorrect = true
exclude "**/test/**"
exclude "**/androidTest/**"
exclude "**/build/**"
exclude "**/resources/**"
exclude "**/tmp/**"
}
// Apply same path exclusions as for the main task
tasks.withType(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask).configureEach() {
exclude "**/test/**"
exclude "**/androidTest/**"
exclude "**/build/**"
exclude "**/resources/**"
exclude "**/tmp/**"
}
allprojects {
repositories {
google()
mavenCentral()
maven {
url "https://nightly.maven.mozilla.org/maven2"
}
maven {
url "https://maven.mozilla.org/maven2"
}
}
}
subprojects {
// Define a reusable task for updating the version in manifest.json for modules that package
// a web extension. We automate this to make sure we never forget to update the version, either
// in local development or for releases. In both cases, we want to make sure the latest version
// of all extensions (including their latest changes) are installed on first start-up.
ext.updateExtensionVersion = { task, extDir ->
configure(task) {
from extDir
include 'manifest.template.json'
rename { 'manifest.json' }
into extDir
def values = ['version': rootProject.ext.config.componentsVersion + "." + new Date().format('MMddHHmmss')]
inputs.properties(values)
expand(values)
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
configurations {
ktlint
}
dependencies {
ktlint("com.pinterest:ktlint:${FocusVersions.ktlint_version}") {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
}
}
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "app/**/*.kt", "!**/build/**/*.kt", "buildSrc/**/*.kt"
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "app/**/*.kt", "!**/build/**/*.kt", "buildSrc/**/*.kt"
}
tasks.register("listRepositories") {
doLast {
println "Repositories:"
project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
}
}
tasks.register("githubTestDetails", GithubDetailsTask) {
text = "### [Unit Test Results]({reportsUrl}/test/testFocusDebugUnitTest/index.html)"
}
tasks.register("githubLintDetektDetails", GithubDetailsTask) {
text = "### [Detekt Results Focus]({reportsUrl}/detekt.html)"
}
tasks.register("githubLintAndroidDetails", GithubDetailsTask) {
text = "### [Android Lint Results Focus]({reportsUrl}/lint-results-debug.html)"
}