-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.gradle
189 lines (152 loc) · 4.79 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
plugins {
id 'groovy'
id 'maven-publish'
id 'jacoco'
id "com.jfrog.bintray" version '1.8.5'
id "pl.allegro.tech.build.axion-release" version "1.12.0"
id "com.dorongold.task-tree" version "1.5"
}
// Drawback in inferring version from git is project can not be built/released without git history in place.
scmVersion {
// release using git info. tag as v<x.y.z>.
tag {
prefix = 'v'
versionSeparator = ''
}
// Do not push using inbuilt git. use native CLI git.
localOnly = true
hooks {
post { context ->
/// Pushing tags manually thru native git client because jgit requires authentication via a pop-up
println "pushing tag: v${context.currentVersion}"
exec {
commandLine 'git', 'push', 'origin', "v${context.currentVersion}"
}
}
}
}
/**
# Check current inferred version:
$ ./gradlew currentVersion
# Marking next version, which is non patch increment
$ ./gradlew markNextVersion -Prelease.nextVersion=2.0.0
# Dry Run
$ ./gradlew release -Prelease.dryRun
# Releasing a version
$ ./gradlew release
# Upload
$ ./gradlew bintrayUpload
*/
// Important: infer project's version from scm (git), this must be configured after scmVersion block
project.version = scmVersion.version
group = 'io.github.kdabir.gstorm'
description = "Groovy Single Table ORM"
/**
* Support Java8+ : as a library, we cannot enforce latest java version
*/
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main.groovy.srcDirs = ['src']
test.groovy.srcDirs = ['test']
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
compileOnly 'org.codehaus.groovy:groovy-all:3.0.10'
implementation 'org.hsqldb:hsqldb:2.6.1'
implementation 'org.slf4j:slf4j-api:1.7.36'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.codehaus.groovy:groovy-all:3.0.10'
testImplementation 'io.github.kdabir.directree:directree:0.3.2'
}
jar {
manifest {
attributes 'Implementation-Title': 'Gstorm',
'Implementation-Version': version,
'Built-By': System.getProperty("user.name"),
'Built-Date': new Date(),
'Built-JDK': System.getProperty("java.version"),
'Built-Gradle': gradle.gradleVersion
}
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
task groovydocJar(type: Jar, dependsOn: groovydoc) {
classifier = 'groovydoc'
from groovydoc.destinationDir
}
artifacts {
archives sourcesJar
archives groovydocJar
}
publishing {
publications {
gstormMaven(MavenPublication) {
from components.java
artifact sourcesJar
artifact groovydocJar
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
description project.description
url "https://github.com/kdabir/gstorm"
developers {
developer {
id 'kdabir'
name 'Kunal Dabir'
}
}
scm {
url 'https://github.com/kdabir/gstorm'
connection 'scm:git://github.com/kdabir/gstorm.git'
developerConnection 'scm:git://github.com/kdabir/gstorm.git'
}
licenses {
license {
name 'MIT License'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
}
}
}
} // withXml
}
}
}
// set bintrayUser & bintrayKey in gradle.properties
bintray {
user = getPropertyOrUseDefault("bintrayUser", "fake_user")
key = getPropertyOrUseDefault("bintrayKey", "fake_key")
publications = ['gstormMaven']
def projectName = project.name
def projectDescription = project.description
pkg {
repo = 'maven'
name = projectName // somehow project.* doesn't work in this closure
desc = projectDescription
licenses = ['MIT']
vcsUrl = 'https://github.com/kdabir/gstorm'
}
dryRun = false // whether to run this as dry-run, without deploying
}
String getPropertyOrUseDefault(String propertyName, String defaultValue) {
hasProperty(propertyName) ? getProperty(propertyName) : defaultValue
}
test {
testLogging {
events "failed"
exceptionFormat "full"
}
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
}