-
Notifications
You must be signed in to change notification settings - Fork 71
/
build.gradle
206 lines (176 loc) · 6.46 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
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath Deps.tools_android_gradle_plugin
classpath Deps.tools_bintray_gradle_plugin
classpath Deps.tools_kotlin_gradle_plugin
classpath Deps.androidx_benchmark_gradle_plugin
}
}
def gradleBuildDir = System.getenv('GRADLE_BUILD_DIR')
if (gradleBuildDir != null) {
println "[Configuration] Building project in ${gradleBuildDir}"
allprojects {
buildDir = "${gradleBuildDir}/${project.name}"
}
}
def bintrayProjects = [ "adblock-android", "adblock-android-settings", "adblock-android-webview" ]
// Sub-projects common config
subprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
// apply to all subprojects
// in order to check a subproject, run gradlew `:<subproj_name>:checkstyle`,
// for example: `gradlew :adblock-android-settings:checkstyle`
apply plugin: 'checkstyle'
checkstyle {
// assign the latest checkstyle version explicitly
// the default version is very old, like 5.9
toolVersion = Vers.checkstyle
// a reference checkstyle.xml is here:
// https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-8.39/src/main/resources/google_checks.xml
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}
task checkstyleMain(type: Checkstyle) {
description 'Check code style of main source set'
group 'verification'
source 'src/main/java'
include '**/*.java'
// empty classpath
classpath = rootProject.files()
}
task checkstyleAndroidTest(type: Checkstyle) {
description 'Check code style of android connected tests'
group 'verification'
source 'src/androidTest/java'
include '**/*.java'
// empty classpath
classpath = rootProject.files()
}
task checkstyleTest(type: Checkstyle) {
description 'Check code style of tests source set'
group 'verification'
source 'src/androidTest/java'
include '**/*.java'
// empty classpath
classpath = rootProject.files()
}
tasks.register('checkstyle') {
dependsOn checkstyleMain
dependsOn checkstyleTest
dependsOn checkstyleAndroidTest
}
task listAllDependencies(type: DependencyReportTask) {}
// Configure bintray publication for selected sub-projects
if (name in bintrayProjects) {
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath Deps.tools_bintray_gradle_plugin
}
}
// First, let's apply the maven and bintray related plugins
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven'
apply plugin: 'maven-publish'
def projectName = hasProperty('libraryName') ? libraryName : project.name
// Add bintray.pkg.desc per project
bintray {
user = hasProperty('bintrayUser') ? project.bintrayUser
: System.getenv('BINTRAY_USERNAME')
key = hasProperty('bintrayKey') ? project.bintrayKey
: System.getenv('BINTRAY_KEY')
dryRun = project.hasProperty('dryRun') ? project.dryRun.toBoolean() : true
publish = true
override = true
publications = ['artifactPublication']
pkg {
issueTrackerUrl = Bintray.issueTracker
licenses = Bintray.licences
name = projectName
repo = 'maven'
userOrg = Bintray.userOrg
vcsUrl = Bintray.repository
websiteUrl = Bintray.website
version {
name = Config.moduleVersion
vcsTag = Config.moduleVersion
}
}
} // end of bintray
afterEvaluate {
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
android.libraryVariants.all { variant ->
if (variant.name == 'release') {
owner.classpath += variant.javaCompileProvider.get().classpath
}
}
exclude '**/R.java', '**/R.html', '**/R.*.html', '**/index.html'
failOnError false
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier.set("sources")
}
task javadocsJar(type: Jar, dependsOn: androidJavadocs) {
from androidJavadocs.destinationDir
archiveClassifier.set('javadoc')
}
uploadArchives {
repositories.mavenDeployer {
pom.groupId = projectName
pom.artifactId = project.archivesBaseName
pom.version = Config.moduleVersion
repository(url: Bintray.repository)
}
}
publishing {
publications {
artifactPublication(MavenPublication) {
// Define this explicitly if using implementation or api configurations
pom.withXml {
def dependenciesNode = asNode().getAt('dependencies')[0] ?: asNode()
.appendNode('dependencies')
if (projectName != 'adblock-android') {
// Maven can't pick up adblock-android dependency right, adding manually
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', 'org.adblockplus')
dependencyNode.appendNode('artifactId', 'adblock-android')
dependencyNode.appendNode('version', Config.moduleVersion)
}
// Iterate over the implementation dependencies, we don't want the test ones
configurations.implementation.allDependencies.each {
if (it.name != 'unspecified' && it.version != 'unspecified') {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
def postfix = projectName == 'adblock-android' ? "-abi_all" : ""
artifact("$buildDir/outputs/aar/" + projectName + postfix + "-release.aar")
artifact(sourcesJar)
artifact(javadocsJar)
groupId Bintray.groupId
artifactId projectName
version Config.moduleVersion
}
}
} // end of publishing
} // end of afterEvaluate
} // end of bintray configuration
} // end of sub-projects common config