-
Notifications
You must be signed in to change notification settings - Fork 174
/
publish.gradle
127 lines (110 loc) · 4.38 KB
/
publish.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
/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* To publish a driver to Maven local:
* ./gradlew -PPUBLISHING [driver_name]:clean [driver_name]:publishToMavenLocal
*
* To publish a driver to Bintray:
* Set environmental variables BINTRAY_USER and BINTRAY_API_KEY to proper values and run
* ./gradlew -PPUBLISHING [driver_name]:clean [driver_name]:bintrayUpload
*
* Additionally, add the -PSNAPSHOT flag to replace artifact version names with "SNAPSHOT". Note
* that bintrayUpload tasks will not upload the artifact if this flag is used.
*/
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
}
String publicationName = 'driverPublish'
boolean snapshot = hasProperty "SNAPSHOT"
subprojects {
if (!project.findProperty("ARTIFACT_VERSION")) {
return
}
apply plugin: 'com.android.library'
task genJavadocs(type: Javadoc) {
// For each project, generate Javadoc and include it as an artifact
source = android.sourceSets.main.java.sourceFiles
// Manually select the current version of Android
project.android.compileSdkVersion = 'android-' + DEFAULT_COMPILE_SDK_VERSION
// Make sure compiled dependencies can be handled for Javadoc
// e.g: for androidthings support library.
configurations.compileOnly.setCanBeResolved(true)
classpath += configurations.compileOnly
// Make sure implemented dependencies can be handled for Javadoc
// e.g: for annotation support library.
configurations.implementation.setCanBeResolved(true)
classpath += configurations.implementation
}
task sourceJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
task javadocJar(type: Jar, dependsOn: genJavadocs) {
classifier = 'javadoc'
from genJavadocs.destinationDir
}
def artifactVersion = snapshot ? "LATEST" : ARTIFACT_VERSION
publishing.publications {
"$publicationName"(MavenPublication) {
groupId 'com.google.android.things.contrib'
artifactId "driver-$project.name"
version artifactVersion
artifact sourceJar
artifact javadocJar
artifact("$buildDir/outputs/aar/$project.name-release.aar")
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
(configurations.compile.allDependencies + configurations.api.allDependencies).each {
if (it.group != null
&& it.name != null && !"unspecified".equals(it.name)
&& it.version != null && !"unspecified".equals(it.version)) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_API_KEY')
publications = [publicationName]
publish = true
dryRun = snapshot
pkg {
repo = 'androidthings'
name = "contrib-driver-$project.name"
userOrg = 'google'
version {
name = artifactVersion
gpg {
sign = true
}
}
}
}
afterEvaluate {
tasks.withType(PublishToMavenRepository).all { publishTask ->
publishTask.dependsOn build
}
tasks.withType(PublishToMavenLocal).all { publishTask ->
publishTask.dependsOn build
}
}
}