-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
239 lines (195 loc) · 6.52 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
buildscript {
if ("$gradle.gradleVersion" != "7.2") {
throw new GradleException("Gradle version 7.2 is required (received $gradle.gradleVersion)")
}
// https://github.com/gradle/gradle/issues/11308#issuecomment-554317655
if (System.properties['org.gradle.internal.publish.checksums.insecure'] != 'true') {
throw new GradleException("org.gradle.internal.publish.checksums.insecure must be 'true'")
}
repositories {
mavenCentral()
google()
}
ext.kotlin_version = "1.5.30"
dependencies {
classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:5.3.0"
classpath "com.vanniktech:gradle-android-junit-jacoco-plugin:0.16.0"
classpath "digital.wup:android-maven-publish:3.6.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.android.tools.build:gradle:7.0.2"
classpath "de.undercouch:gradle-download-task:4.1.2"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.8.0.0"
}
}
plugins {
id "com.github.ben-manes.versions" version "0.33.0"
id "com.vanniktech.android.junit.jacoco" version "0.16.0"
id "ru.vyarus.animalsniffer" version "1.5.1"
id "ca.cutterslade.analyze" version "1.4.3"
id "maven-publish"
}
ext {
androidBuildToolsVersion = "30.0.2"
androidCompileSDKVersion = 28
androidMinimumSDKVersion = 21
androidTargetSDKVersion = 28
if (!project.hasProperty("mavenCentralUsername")) {
logger.warn("No mavenCentralUsername property specified: Using an empty value")
mavenCentralUsername = ""
}
if (!project.hasProperty("mavenCentralPassword")) {
logger.warn("No mavenCentralPassword property specified: Using an empty value")
mavenCentralPassword = ""
}
if (project.hasProperty("org.librarysimplified.directory.publish")) {
useDirectoryPublishPath = project.property("org.librarysimplified.directory.publish")
useDirectoryPublish = true
logger.warn("org.librarysimplified.directory.publish is set: We will publish artifacts to ${useDirectoryPublishPath}")
} else {
logger.warn("org.librarysimplified.directory.publish is not set: We will not publish artifacts to a custom directory")
useDirectoryPublish = false
useDirectoryPublishPath = null
}
if (project.hasProperty("org.librarysimplified.no_signing")) {
disableSigning = true
logger.warn("org.librarysimplified.no_signing is set: We will not sign artifacts")
} else {
disableSigning = false
logger.warn("org.librarysimplified.no_signing is not set: We will attempt to sign artifacts")
}
}
apply plugin: "com.vanniktech.android.junit.jacoco"
apply plugin: "de.undercouch.download"
allprojects { project ->
group = project.ext["GROUP"]
version = project.ext["VERSION_NAME"]
apply plugin: 'ca.cutterslade.analyze'
}
// Configure all projects
subprojects { project ->
switch (POM_PACKAGING) {
case "jar":
logger.info("Configuring ${project} ${version} (${POM_PACKAGING}) as jar project")
apply plugin: "java"
apply plugin: "java-library"
apply plugin: "kotlin"
/*
* Apply the Animal Sniffer plugin to check that code is Android compatible.
*/
apply plugin: "ru.vyarus.animalsniffer"
dependencies {
signature "org.codehaus.mojo.signature:java16:1.1@signature"
signature "net.sf.androidscents.signature:android-api-level-21:5.0.1_r2@signature"
}
/*
* Build an OSGi bundle.
*/
apply plugin: "biz.aQute.bnd.builder"
jar {
bnd """
Automatic-Module-Name: ${POM_AUTOMATIC_MODULE_NAME}
-removeheaders: Bnd-LastModified, Tool, Private-Package
"""
}
break
case "apk":
logger.info("Configuring ${project} ${version} (${POM_PACKAGING}) as Android application project")
apply plugin: "com.android.application"
apply plugin: "kotlin-android"
android {
compileSdkVersion androidCompileSDKVersion
buildToolsVersion androidBuildToolsVersion
defaultConfig {
minSdkVersion androidMinimumSDKVersion
targetSdkVersion androidTargetSDKVersion
}
compileOptions {
encoding 'UTF-8'
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
break
case "aar":
logger.info("Configuring ${project} ${version} (${POM_PACKAGING}) as Android library project")
apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "de.mannodermaus.android-junit5"
android {
compileSdkVersion androidCompileSDKVersion
buildToolsVersion androidBuildToolsVersion
defaultConfig {
minSdkVersion androidMinimumSDKVersion
targetSdkVersion androidTargetSDKVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
}
compileOptions {
encoding 'UTF-8'
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
testOptions {
junitPlatform {
releaseFilters {
excludePattern "**/**"
}
}
unitTests.includeAndroidResources = true
unitTests.all {
reports {
junitXml.enabled = true
html.enabled = true
}
}
}
}
break
default:
throw new IllegalStateException(
"Unrecognized packaging type ${POM_PACKAGING} for ${project}")
}
/*
* Configure publishing for the various project types.
*/
switch (POM_PACKAGING) {
case "jar":
apply from: file("$rootDir/build_publishing.gradle")
break
case "apk":
break
case "aar":
apply from: file("$rootDir/build_publishing.gradle")
break
default:
throw new IllegalStateException(
"Unrecognized packaging type ${POM_PACKAGING} for ${project}")
}
repositories {
mavenLocal()
mavenCentral()
google()
// Sonatype snapshots
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven { url "https://jitpack.io" }
}
}
/**
* An empty task called by CI. We don't do semantic versioning analysis here yet.
*/
task verifySemanticVersioning {}
/*
* Add ktlint tasks.
*/
apply from: file("$rootDir/build_ktlint.gradle")
subprojects {
assemble.dependsOn ktlint
}