-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
134 lines (108 loc) · 3.11 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
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.ajoberstar:grgit:2.1.0'
classpath 'org.ajoberstar.reckon:reckon-gradle:0.3.0'
classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
}
}
apply plugin: 'java-library'
apply plugin: "org.ajoberstar.grgit"
apply plugin: "org.ajoberstar.reckon"
apply plugin: 'com.bmuschko.nexus'
group = "cl.daplay"
description = "Rut implementation in Java"
reckon {
normal = scopeFromProp()
preRelease = snapshotFromProp()
}
repositories {
mavenCentral()
jcenter()
}
targetCompatibility = 1.5
sourceCompatibility = 1.5
dependencies {
testImplementation 'junit:junit:4.12'
}
ext {
versionPattern = /\d+\.\d+\.\d+/
}
def requireReleaseVersion(alert = "") {
// execute if not snapshot and matches \d.\d.\d
def execute = !version.toString().contains("SNAPSHOT") && (version.toString() ==~ versionPattern)
if (!execute && alert) {
println alert
}
return execute;
}
task readmeUpdate {
description = 'Updateso version in README.md'
onlyIf {
def alert = "README.md won't be updated, as $version is an SNAPSHOT version"
return requireReleaseVersion(alert)
}
// handle to README.md
def readme = new File(project.projectDir, "README.md")
// replace text in README.md
doLast {
def text = readme.text
readme.text = text.replaceAll versionPattern, version.toString()
}
// add, commit and push change
doLast {
grgit.add(patterns: ['README.md'])
grgit.commit(message: "chore(README.md) releases version: '${version.toString()}'.")
grgit.push()
}
}
task release() {
onlyIf {
def alert = "task Release, won't be executed, as $version is an SNAPSHOT version"
return requireReleaseVersion(alert)
}
final String releaseName = "v${version}"
doLast {
println "releasing: $releaseName"
grgit.tag.add(name: releaseName, message: releaseName, annotate: true)
grgit.push(refsOrSpecs: ["refs/tags/${releaseName}"])
}
}
release.dependsOn build
release.dependsOn readmeUpdate
release.finalizedBy uploadArchives
readmeUpdate.mustRunAfter(build)
// unused tasks by plugin Reckon
project.tasks.remove(reckonTagCreate)
project.tasks.remove(reckonTagPush)
modifyPom {
project {
name project.name
description project.description
url 'https://github.com/daplay/jrut'
scm {
url 'https://github.com/daplay/jrut'
connection 'scm:https://github.com/daplay/jrut.git'
developerConnection 'scm:git://github.com/daplay/jrut.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'daplay'
name 'Daniel Meneses'
email '[email protected]'
}
}
}
}