-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
160 lines (135 loc) · 5.18 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
/*
* Copyright (c) 2014-2017 Afero, Inc. All rights reserved.
*/
buildscript {
repositories {
google()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.15.2'
classpath "com.mobbeel.plugin:fat-aar:2.0.1"
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Closure<Boolean> isCIBuild = { ->
return System.getenv('BUILD_NUMBER')
}
Closure<String> getCommandLineOutput = { ...args ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine args
standardOutput = stdout
}
return stdout.toString().trim()
}
Closure<String> gitDescribeFull = { match ->
return getCommandLineOutput('git', 'describe', '--match', match ?: '*')
}
Closure<String> gitDescribeAbbrev = { match ->
return getCommandLineOutput('git', 'describe', '--match', match ?: '*', '--abbrev=0')
}
Closure<String> gitConfigEmail = { ->
return getCommandLineOutput('git', 'config', 'user.email')
}
Closure<String> getSDKVersion = { ->
if (project.findProperty('aferoSDKBranchName')) {
final String tagBranch = "-${project.aferoSDKBranchName}"
final String versionTagMatch = "v*${tagBranch}"
String version
final String buildLabel = project.findProperty('aferoBuildLabel') ?: ''
try {
if (isCIBuild()) {
version = gitDescribeFull(versionTagMatch).replace(tagBranch, "") + buildLabel
} else {
String user = gitConfigEmail().split("@").getAt(0)
version = gitDescribeAbbrev(versionTagMatch).replace(tagBranch, "") + '-dev-' + user + buildLabel
}
// drop the 'v' and the branch name
return version.drop(1)
}
catch(e) {
logger.log(LogLevel.ERROR, "Error: getSDKVersion failed, probably couldn't find version tag")
throw e
}
}
return ''
}
String sdkVersion = getSDKVersion()
group = 'io.afero.sdk'
version = sdkVersion
status = project.findProperty('aferoSDKBranchName') ?: 'develop'
artifactory {
contextUrl = 'https://afero.jfrog.io/afero'
publish {
repository {
repoKey = project.findProperty('aferoSDKDeployRepoKey') ?: 'afero-java-sdk'
username = project.aferoArtifactoryUserName
password = project.aferoArtifactoryPassword
}
defaults {
publications('aar', 'jar')
publishArtifacts = true
publishPom = true
publishBuildInfo = true
}
}
clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER') ?: 'dev')
}
artifactoryPublish {
onlyIf {
if (sdkVersion.isEmpty()) {
logger.log(LogLevel.WARN, "Warning: sdkVersion is empty - skipping artifactoryPublish")
return false
}
return true
}
}
gradle.projectsEvaluated {
Set<Project> javaSubprojects = subprojects.findAll { subproject -> subproject.plugins.hasPlugin(JavaPlugin) }
Set<Project> androidSubprojects = rootProject.subprojects.findAll { subproject -> subproject.plugins.findPlugin("com.android.library") }
task aggregateJavadocs(type: Javadoc) {
description = 'Aggregates Javadoc API documentation of all subprojects.'
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn javaSubprojects.javadoc //, androidSubprojects.androidJavadocs
title 'Afero Java SDK'
options.windowTitle title
source javaSubprojects.javadoc.source //, androidSubprojects.androidJavadocs.source
destinationDir rootProject.file("$rootProject.buildDir/docs/javadoc")
classpath = rootProject.files(javaSubprojects.javadoc.classpath) //, androidSubprojects.androidJavadocs.classpath)
// allow html tags
options.addStringOption('Xdoclint:none', '-quiet')
// collect all the -link options from subprojects
def links = new HashSet<String>();
links.add("http://docs.oracle.com/javase/7/docs/api/")
links.addAll(javaSubprojects.javadoc.options.links.collectMany { it })
// links.addAll(androidSubprojects.androidJavadocs.options.links.collectMany { it })
options.addMultilineStringsOption('link').setValue(links.toList())
// collect all the -linksoffline options from subprojects
def linksOffline = new HashMap<String, ArrayList<String>>();
javaSubprojects.javadoc.options.linksOffline.each { lo ->
lo.each { l ->
linksOffline.put(l.getExtDocUrl(), [l.getExtDocUrl(), l.getPackagelistLoc()].join("' '"))
}
}
// androidSubprojects.androidJavadocs.options.linksOffline.each { lo ->
// lo.each { l ->
// linksOffline.put(l.getExtDocUrl(), [l.getExtDocUrl(), l.getPackagelistLoc()].join("' '"))
// }
// }
options.addMultilineStringsOption('linkoffline').setValue(linksOffline.values().toList())
}
}