-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
139 lines (113 loc) · 3.97 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
buildscript {
repositories {
maven { url "$rootDir/../../prebuilts/tools/common/gradle-plugins/repository" }
}
dependencies {
classpath 'com.android.tools.internal:internal-plugins:1.0'
}
}
apply plugin: 'clone-artifacts'
apply plugin: 'distrib'
// artifact cloning destinations
cloneArtifacts {
mainRepo = "$rootDir/../../prebuilts/tools/common/m2/repository"
secondaryRepo = "$rootDir/../../prebuilts/tools/common/m2/internal"
}
// set up the distribution destination
distribution {
destinationPath = "$rootDir/../../prebuilts/devtools"
dependenciesRepo = cloneArtifacts.mainRepo
}
// ext.androidHostOut is shared by all tools/{base,build,swt} gradle projects/
ext.androidHostOut = file("$rootDir/../../out/host/gradle")
ext.androidRootDir = file(new File(ext.androidHostOut, "../../../"))
// rootProject.buildDir is specific to this gradle build.
buildDir = new File(file(ext.androidHostOut), "tools/base/build")
ext.localRepo = project.hasProperty('localRepo') ? localRepo : "$ext.androidHostOut/repo"
def getVersion(Project p, String baseVersion) {
if (p.has("release")) {
return baseVersion
}
return baseVersion + '-SNAPSHOT'
}
subprojects { Project project ->
// Change buildDir first so that all plugins pick up the new value.
project.buildDir = project.file("$project.parent.buildDir/../$project.name")
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'findbugs'
apply plugin: 'distrib'
apply plugin: 'clone-artifacts'
repositories {
maven { url = uri(rootProject.cloneArtifacts.mainRepo) }
maven { url = uri(rootProject.cloneArtifacts.secondaryRepo) }
}
// find bug dependencies is added dynamically so it's hard for the
// clone artifact plugin to find it. This custom config lets us manually
// add such dependencies.
configurations {
hidden
}
dependencies {
hidden "com.google.code.findbugs:findbugs:2.0.1"
}
version = getVersion(project, '22.2.0')
project.ext.sonatypeUsername = project.hasProperty('sonatypeUsername') ? sonatypeUsername : ""
project.ext.sonatypePassword = project.hasProperty('sonatypePassword') ? sonatypePassword : ""
// set all java compilation to use UTF-8 encoding.
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
task disableTestFailures << {
tasks.withType(Test) {
ignoreFailures = true
}
}
// custom tasks for creating source/javadoc jars
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
// add javadoc/source jar tasks as artifacts
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
task publishLocal(type: Upload) {
configuration = configurations.archives
repositories {
mavenDeployer {
repository(url: uri(rootProject.ext.localRepo))
}
}
}
def userHome = System.getProperty("user.home")
publishLocal.doFirst {
System.setProperty("user.home", file("$buildDir/fakem2home").absolutePath)
}
publishLocal.doLast {
System.setProperty("user.home", userHome)
}
findbugs {
ignoreFailures = true
effort = "max"
reportLevel = "high"
}
signing {
required { project.has("release") && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
}
// delay evaluation of this project before all subprojects have been evaluated.
subprojects.each { subproject -> evaluationDependsOn(subproject.path) }
def testTasks = subprojects.collect { it.tasks.withType(Test) }.flatten()
task aggregateResults(type: Copy) {
from { testTasks*.testResultsDir }
into { file("$buildDir/results") }
}