-
Notifications
You must be signed in to change notification settings - Fork 182
/
build.gradle
249 lines (198 loc) · 10.8 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
import org.gradle.internal.jvm.Jvm
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.71' // https://github.com/JetBrains/kotlin/releases
repositories {
jcenter()
google()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
// Android Gradle plugin
classpath 'com.android.tools.build:gradle:3.2.1'
// Jacoco Test Coverage Plugin
// (addition to standard Jacoco plugin, allows us fail the build if coverage is not enough)
// https://github.com/palantir/gradle-jacoco-coverage
classpath 'com.palantir:jacoco-coverage:0.2.0'
// Kotlin
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Automatic releases to Sonatype.
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.12.0' // https://github.com/Codearte/gradle-nexus-staging-plugin/releases
classpath "de.marcphilipp.gradle:nexus-publish-plugin:0.1.1" // https://github.com/marcphilipp/nexus-publish-plugin/releases
// classpath 'com.squareup.sqldelight:gradle-plugin:1.0.0-rc2'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
// Workaround for preventing Gradle from stealing focus from other apps
// https://gist.github.com/artem-zinnatullin/4c250e04636e25797165
tasks.withType(JavaForkOptions) {
jvmArgs '-Djava.awt.headless=true'
}
}
ext {
compileSdkVersion = 28
minSdkVersion = 14
}
def supportLibsVersion = '28.0.0'
def daggerVersion = '2.18'
ext.libraries = [
// Core libraries
supportAnnotations : 'com.android.support:support-annotations:' + supportLibsVersion,
rxJava2 : 'io.reactivex.rxjava2:rxjava:2.1.6',
rxAndroid2 : 'io.reactivex.rxjava2:rxandroid:2.0.1',
kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
// Parts of StorIO
storIOCommon : project(':storio-common'),
storIOSQLite : project(':storio-sqlite'),
storIOContentResolver : project(':storio-content-resolver'),
storIOSQLiteAnnotations : project(':storio-sqlite-annotations'),
storIOContentResolverAnnotations : project(':storio-content-resolver-annotations'),
storIOCommonAnnotationsProcessor : project(':storio-common-annotations-processor'),
storIOSQLiteAnnotationsProcessor : project(':storio-sqlite-annotations-processor'),
storIOContentResolverAnnotationsProcessor: project(':storio-content-resolver-annotations-processor'),
storIOTestCommon : project(':storio-test-common'),
// Libraries for tests and sample app
junit : 'junit:junit:4.12',
assertJ : 'org.assertj:assertj-core:3.9.0', // http://joel-costigliola.github.io/assertj/assertj-core-news.html
assertJAndroid : 'com.squareup.assertj:assertj-android:1.2.0', // https://github.com/square/assertj-android/blob/master/CHANGELOG.md
mockitoCore : 'org.mockito:mockito-core:2.13.0', // https://github.com/mockito/mockito/blob/release/2.x/doc/release-notes/official.md
mockitoKotlin : 'com.nhaarman:mockito-kotlin:1.5.0', // https://github.com/nhaarman/mockito-kotlin/releases
equalsVerifier : 'nl.jqno.equalsverifier:equalsverifier:1.7.8', // http://jqno.nl/equalsverifier/changelog/#1.x
privateConstructorChecker : 'com.pushtorefresh.java-private-constructor-checker:checker:1.2.0', // https://github.com/pushtorefresh/java-private-constructor-checker/blob/master/CHANGELOG.md
guava : 'com.google.guava:guava:18.0',
robolectric : 'org.robolectric:robolectric:3.5.1',
googleTestingCompile : 'com.google.testing.compile:compile-testing:0.15',
dagger : 'com.google.dagger:dagger:' + daggerVersion,
daggerCompiler : 'com.google.dagger:dagger-compiler:' + daggerVersion,
javaxInject : 'javax.inject:javax.inject:1',
javaxAnnotationApi : 'javax.annotation:javax.annotation-api:1.2',
butterKnife : "com.jakewharton:butterknife:7.0.1",
appCompat : "com.android.support:appcompat-v7:$supportLibsVersion",
recyclerView : "com.android.support:recyclerview-v7:$supportLibsVersion",
appCompatX : "androidx.appcompat:appcompat:1.0.0",
recyclerViewX : "androidx.recyclerview:recyclerview:1.0.0",
timber : "com.jakewharton.timber:timber:4.6.0", // https://github.com/JakeWharton/timber/blob/master/CHANGELOG.md
leakCanary : "com.squareup.leakcanary:leakcanary-android:1.5.4", // https://github.com/square/leakcanary/blob/master/CHANGELOG.md
leakCanaryNoOp : "com.squareup.leakcanary:leakcanary-android-no-op:1.5.4",
sqlDelight : "com.squareup.sqldelight:runtime:0.6.1",
javaPoet : 'com.squareup:javapoet:1.8.0',
intellijAnnotations : 'com.intellij:annotations:12.0',
runtimeJar : files(getRuntimeJar()),
toolsJar : files(Jvm.current().getToolsJar()),
autoService : "com.google.auto.service:auto-service:1.0-rc4", // https://github.com/google/auto/releases
autoValue : "com.google.auto.value:auto-value:1.3",
autoParcel : "com.github.frankiesardo:auto-parcel:0.3.1", // https://github.com/frankiesardo/auto-parcel/releases
autoParcelProcessor : "com.github.frankiesardo:auto-parcel-processor:0.3.1"
]
def getRuntimeJar() {
try {
final File javaBase = new File(System.getProperty("java.home")).getCanonicalFile();
File runtimeJar = new File(javaBase, "lib/rt.jar");
if (runtimeJar.exists()) {
return runtimeJar;
}
runtimeJar = new File(javaBase, "jre/lib/rt.jar");
return runtimeJar.exists() ? runtimeJar : null;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// Option to disable Pre-Dexing on CI env
project.ext.preDexLibs = !project.hasProperty('disablePreDex')
subprojects {
apply plugin: 'com.github.ben-manes.versions'
project.plugins.whenPluginAdded { plugin ->
if ('com.android.build.gradle.AppPlugin'.equals(plugin.class.name)
|| 'com.android.build.gradle.LibraryPlugin'.equals(plugin.class.name)) {
// enable or disable pre-dexing
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
// treat all Android Lint warning in all sub-projects as errors
project.android.lintOptions.warningsAsErrors = true
// StorIO should support Java 6
project.android.compileOptions.sourceCompatibility = JavaVersion.VERSION_1_6
project.android.compileOptions.targetCompatibility = JavaVersion.VERSION_1_6
project.android.testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
exceptionFormat 'full'
}
}
}
// Ignore 'debug' buildType for library projects
// Because we don't have debug-specific code and we don't need to build debug variants
// https://gist.github.com/artem-zinnatullin/ec3bce6dcb2cd524c435
if ('com.android.build.gradle.LibraryPlugin'.equals(plugin.class.name)) {
project.android.variantFilter {
if (it.buildType.name.equals('debug')) {
it.ignore = true
}
}
}
}
}
def gitTag() {
def tag = 'git tag --list --points-at HEAD'.execute((List) null, rootProject.projectDir).text.trim()
if (tag.split(System.lineSeparator()).length > 1) {
throw new IllegalStateException("gitTag is accessed but commit has multiple tags: $tag")
}
return tag
}
def projectVersion() {
def tag = gitTag()
if (tag.startsWith('v')) {
return tag.substring(1)
} else if (tag.isEmpty()) {
return 'development'
}
return tag
}
def validateTagAndVersion() {
if (gitTag().isEmpty()) {
throw new IllegalStateException('Publishing is not allowed because current commit has no tag')
}
if (projectVersion().isEmpty()) {
throw new IllegalStateException('Publishing is not allowed because current projectVersion is empty')
}
if ('development'.equals(projectVersion())) {
throw new IllegalStateException('Publishing is not allowed because current projectVersion is "development"')
}
}
def isValidReleaseState() {
if ('true' != System.getenv('PUBLISH_RELEASE')) {
return false
}
try {
validateTagAndVersion()
return true
} catch (Exception e) {
return false
}
}
ext.VERSION_NAME = projectVersion()
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: 'https://oss.sonatype.org/content/repositories/snapshots/'
}
def getRepositoryUsername() {
return System.getenv('SONATYPE_USERNAME')
}
def getRepositoryPassword() {
return System.getenv('SONATYPE_PASSWORD')
}
apply plugin: 'io.codearte.nexus-staging'
nexusStaging {
packageGroup = 'com.pushtorefresh'
username = getRepositoryUsername()
password = getRepositoryPassword()
}