-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
112 lines (98 loc) · 3.92 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
import java.nio.file.FileSystems
import java.nio.file.PathMatcher
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { scriptHandler ->
apply from: 'repositories.gradle',
to: scriptHandler
ext.kotlin_version = "1.4.31"
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'com.diffplug.spotless' version '5.10.2'
id "com.smallraw.plugin" apply false
}
apply from: 'properties.gradle'
ext {
// query git for the commit count to automate versioning.
gitCommitCount = 100 +
Integer.parseInt('git rev-list --count HEAD master'.execute([], project.rootDir).text.trim())
def pros = readProperties('spotlessconfig.properties')
ignoreSpotless = []
if (pros.containsKey('ignoreSpotless')) {
ignoreSpotless = pros.getProperty('ignoreSpotless').split(',')
}
enableSpotless = true
if (project.hasProperty("spotlessEnable")) {
enableSpotless = project.spotlessEnable
} else if (pros.containsKey('enableSpotless')) {
enableSpotless = pros.getProperty('enableSpotless')
}
}
subprojects {
buildscript {
apply from: rootProject.file('repositories.gradle')
}
def ignoreSpotlessPath = false
for (String item : rootProject.ignoreSpotless) {
PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + item)
if (matcher.matches(projectDir.toPath())) {
println "Spotless ignores the path: " + projectDir.path
ignoreSpotlessPath = true
break
}
}
if (rootProject.enableSpotless == true && !ignoreSpotlessPath) {
println "Spotless works at : " + projectDir.path
apply plugin: 'com.diffplug.spotless'
spotless {
java {
// This path needs to be relative to each project
target fileTree('.') {
include('**/src/*/java/**/*.java')
exclude '**/.gradle/**'
exclude '**/generated/**'
exclude '**/build/install/**'
}
removeUnusedImports()
googleJavaFormat("1.7").aosp()
importOrder 'java', '', 'com.smallraw', '\\#'
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile "$rootDir/gradle/spotless/java.license"
}
kotlin {
// This path needs to be relative to each project
target fileTree('.') {
include('**/*.kt')
exclude '**/.gradle/**'
exclude '**/build/install/**'
}
// see https://github.com/shyiko/ktlint#standard-rules
// see https://github.com/pinterest/ktlint#editorconfig
// see https://github.com/diffplug/spotless/issues/142
ktlint(Versions.ktlint)
.userData(['indent_si1ze' : '2',
'continuation_indent_size': '2',
'android' : 'true',
'max_line_length' : '156',
'disabled_rules' : "no-wildcard-imports,experimental:annotation"])
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile "$rootDir/gradle/spotless/java.license"
}
groovyGradle {
target '**.gradle'
greclipse().configFile("$rootDir/gradle/spotless/formatter.properties")
endWithNewline()
indentWithSpaces(4)
}
kotlinGradle {
target '**.gradle.kts'
ktlint(Versions.ktlint)
}
}
}
}