forked from ksoichiro/gradle-build-info-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
241 lines (203 loc) · 6.32 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
}
dependencies {
classpath "com.gradle.publish:plugin-publish-plugin:0.9.1"
}
}
plugins {
id 'maven'
id 'maven-publish'
id 'com.jfrog.bintray' version '1.2'
id 'net.saliman.cobertura' version '2.2.8'
id 'com.github.kt3k.coveralls' version '2.3.1'
id 'com.github.ksoichiro.console.reporter' version '0.3.4'
}
apply plugin: 'idea'
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'signing'
apply plugin: 'com.gradle.plugin-publish'
apply from: "${rootDir}/gradle/version.gradle"
group = GROUP
version = PLUGIN_VERSION
archivesBaseName = POM_ARTIFACT_ID
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
mavenCentral()
jcenter()
}
task createClasspathManifest {
def outputDir = file("$buildDir/$name")
inputs.files sourceSets.main.runtimeClasspath
outputs.dir outputDir
doLast {
outputDir.mkdirs()
file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n")
}
}
dependencies {
compile gradleApi()
compile localGroovy()
compile 'org.ajoberstar:grgit:1.4.1'
testRuntime files(createClasspathManifest)
testCompile gradleTestKit()
testCompile 'org.springframework.boot:spring-boot-starter-actuator:1.3.0.RELEASE'
}
idea.module.excludeDirs += [
file('samples/repo'),
]
fileTree(dir: "samples").visit { details ->
if (details.name in ['.gradle', 'build']) {
idea.module.excludeDirs << details.file
}
}
cobertura {
coverageFormats = ['html', 'xml']
}
check.dependsOn 'cobertura'
// To release:
// ./gradlew clean assemble uploadArchives -Prelease
def isReleaseBuild
if (hasProperty("release")) {
isReleaseBuild = true
}
def sonatypeRepositoryUrl
if (isReleaseBuild) {
if ("$version".endsWith('-SNAPSHOT')) {
println "SNAPSHOT BUILD $version"
sonatypeRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
} else {
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") : ""
def bintrayUsername = hasProperty("bintrayUsername") ? project.getProperty("bintrayUsername") : ""
def bintrayApiKey = hasProperty("bintrayApiKey") ? project.getProperty("bintrayApiKey") : ""
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'))
}
}
}
}
// Enable this closure when executing uploadArchives
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) {
classifier = 'javadoc'
from groovydoc
}
artifacts {
archives sourcesJar
archives javadocJar
}
publishing {
publications {
plugin(MavenPublication) {
groupId GROUP
artifactId POM_ARTIFACT_ID
version PLUGIN_VERSION
from components.java
artifact sourcesJar
artifact javadocJar
}
}
}
}
bintray {
user = bintrayUsername
key = bintrayApiKey
publications = ['plugin']
pkg {
repo = 'maven'
name = POM_NAME
desc = POM_DESCRIPTION
websiteUrl = POM_URL
issueTrackerUrl = BINTRAY_ISSUE_TRACKER_URL
vcsUrl = BINTRAY_VCS_URL
licenses = ['Apache-2.0']
labels = ['build', 'git', 'java', 'spring-boot']
publicDownloadNumbers = true
version {
attributes = ['gradle-plugin': 'com.github.ksoichiro.build.info:com.github.ksoichiro:gradle-build-info-plugin']
}
}
}
pluginBundle {
website = POM_URL
vcsUrl = BINTRAY_VCS_URL
description = POM_DESCRIPTION
plugins {
plugin {
id = GRADLE_PLUGIN_ID
displayName = POM_NAME
tags = ['build', 'git', 'java', 'spring-boot']
}
}
mavenCoordinates {
artifactId = POM_ARTIFACT_ID
}
}