-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
116 lines (98 loc) · 3.22 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
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'
group = GROUP
version = VERSION_NAME
// To release:
// ./gradlew clean release uploadArchive -Prelease
def isReleaseBuild
if (hasProperty("release")) {
isReleaseBuild = true
}
def sonatypeRepositoryUrl
if (isReleaseBuild) {
println "RELEASE BUILD $version"
sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
} else {
println "DEBUG BUILD $version"
sonatypeRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
}
// Note: These properties must be defined in ~/.gradle/gradle.properties
// and signing.keyId, signing.password, signing.secretKeyRingFile, too.
def username = hasProperty("nexusUsername") ? project.getProperty("nexusUsername") : ""
def password = hasProperty("nexusPassword") ? project.getProperty("nexusPassword") : ""
dependencies {
compile gradleApi()
compile localGroovy()
}
repositories {
mavenCentral()
}
install {
repositories.mavenInstaller {
pom.artifactId = POM_ARTIFACT_ID
}
}
afterEvaluate { project ->
uploadArchives {
if (isReleaseBuild) {
repositories {
mavenDeployer {
beforeDeployment { deployment -> signing.signPom(deployment) }
repository(url: sonatypeRepositoryUrl) {
authentication(userName: username, password: password)
}
pom.project {
name POM_NAME
groupId GROUP
description POM_DESCRIPTION
url POM_URL
inceptionYear POM_INCEPTION_YEAR
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENSE_NAME
url POM_LICENSE_URL
distribution POM_LICENSE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
url POM_DEVELOPER_URL
}
}
}
}
}
} else {
// for development
repositories {
mavenDeployer {
repository(url: uri('./samples/repo'))
}
}
}
}
signing {
required { isReleaseBuild && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
}