forked from dropbox/dropbox-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.gradle
77 lines (67 loc) · 2.26 KB
/
release.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
apply plugin: 'java'
apply plugin: 'java-library-distribution'
apply plugin: 'signing'
apply plugin: 'maven'
task releaseTest() {
dependsOn ':proguard:proguardTest'
dependsOn test
dependsOn integrationTest
}
signing {
required {
// don't sign for installing in local maven
gradle.taskGraph.hasTask("uploadArchives") && !project.version.contains("SNAPSHOT")
}
sign configurations.archives
}
// Remember to upload binary with releases on GitHub. Some 3rd party developers still rely on
// manually downloading and managing their dependencies.
distributions {
main {
baseName = project.archivesBaseName
contents {
// Add source JARs
from { sourcesJar.outputs.getFiles() }
from { 'ChangeLog.txt' }
}
}
}
/**
* Verify our SDK version is set correctly in our artifact before uploading. This is to protect
* against any silly mistakes.
*/
def verifySdkVersion(deployment) {
deployment.mainArtifact.file.withInputStream { stream ->
def jar = new java.util.jar.JarInputStream(stream)
def entry = jar.getNextJarEntry()
while (entry != null) {
if (entry.getName().equals("sdk-version.txt")) {
def version = jar.text.trim();
if (!(version ==~ /\d+\.\d+\.\d+/)) {
throw new GradleException("SDK version not in semantic versioning format: " + version +
". Try running './gradlew clean' before uploading archives.");
}
return
}
entry = jar.getNextJarEntry()
}
throw new GradleException("Could not find sdk-version.txt in artifact: " + deployment.mainArtifact.file.absolutePath);
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { deployment ->
verifySdkVersion(deployment)
signing.signPom(deployment)
}
pom = project.basePom
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(
userName: ossrhUsername,
password: ossrhPassword
)
}
}
}
}