-
Notifications
You must be signed in to change notification settings - Fork 29
/
build.gradle
255 lines (223 loc) · 7.67 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
plugins {
id 'java-library'
id 'idea'
id 'maven-publish'
id 'maven'
id 'signing'
id 'pl.allegro.tech.build.axion-release' version '1.10.0'
id 'com.github.johnrengelman.shadow' version '5.0.0'
}
scmVersion {
tag {
prefix = ''
}
}
group = 'uk.sky'
version = scmVersion.version
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
if (!project.hasProperty('ossrhUsername')) {
ext.ossrhUsername = 'dummy'
}
if (!project.hasProperty('ossrhPassword')) {
ext.ossrhPassword = 'dummy'
}
shadowJar {
classifier = 'with-dependencies'
}
repositories {
mavenCentral()
}
configurations {
testCompileAndFunctional
functional.extendsFrom(testCompileAndFunctional)
testCompile.extendsFrom(testCompileAndFunctional)
}
configurations.all {
resolutionStrategy.eachDependency { details ->
if( details.requested.name == 'jna') {
details.useTarget "net.java.dev.jna:jna:5.8.0"
}
}
}
dependencies {
api('com.datastax.oss:java-driver-core:4.11.1')
implementation('org.slf4j:slf4j-api:1.7.25')
implementation('org.awaitility:awaitility:4.2.1')
testImplementation("com.google.guava:guava:25.1-jre")
testImplementation('org.apache.logging.log4j:log4j-core:2.17.0')
testImplementation('junit:junit:4.12')
testImplementation('org.assertj:assertj-core:3.12.2')
testImplementation('org.mockito:mockito-core:2.25.1')
testImplementation('org.powermock:powermock-api-mockito2:2.0.0')
testImplementation('org.powermock:powermock-module-junit4:2.0.0')
testImplementation('org.awaitility:awaitility:4.2.1')
testImplementation('com.datastax.oss.simulacron:simulacron-driver-3x:0.11.0') {
exclude group: 'com.datastax.oss', module: 'native-protocol'
}
testCompileAndFunctional('org.cassandraunit:cassandra-unit:4.3.1.0')
functional('org.slf4j:slf4j-simple:1.7.25')
}
idea {
module {
downloadSources = true
}
}
tasks.wrapper {
gradleVersion = '5.3'
}
tasks.clean {
// Remove temporary directory for embedded Cassandra
delete("${projectDir}/target")
}
final sourcesJar = tasks.register('sourcesJar', Jar) {
group = LifecycleBasePlugin.BUILD_GROUP
classifier = 'sources'
from(sourceSets.main.allJava)
}
final javadocJar = tasks.register('javadocJar', Jar) {
group = LifecycleBasePlugin.BUILD_GROUP
dependsOn(tasks.javadoc)
classifier = 'javadoc'
from(tasks.javadoc.destinationDir)
}
tasks.assemble {
dependsOn(sourcesJar, javadocJar)
}
final testJar = tasks.register('testJar', Jar) {
classifier = 'tests'
from(sourceSets.main.output, sourceSets.test.output)
from({
(configurations.runtimeClasspath + configurations.functional).collect {
it.isDirectory() ? it : zipTree(it)
}
})
manifest {
attributes 'Main-Class': 'uk.sky.cqlmigrate.example.CmdLineEntryPoint'
}
}
tasks.jar {
manifest {
attributes "Main-Class": "uk.sky.cqlmigrate.CqlMigratorImpl"
}
}
final functional = tasks.register('functional') {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = 'Functional test to run the migrateSchema on a jar containing embedded CQL files and have it return successfully.'
mustRunAfter(tasks.test)
final testJarOutputArchive = testJar.flatMap { it.archiveFile }
final Provider<Directory> functionalOutputDir = project.layout.buildDirectory.dir(name)
final Provider<RegularFile> upToDateCheckingFile = project.layout.buildDirectory.file("${name}-up-to-date.txt")
// Explicit lambda casting required in Groovy due to https://github.com/gradle/gradle/issues/4238
final Provider<Directory> cassandraStorageDir = functionalOutputDir.map((Transformer<Directory, Directory>) { it.dir('cassandra-storage') })
inputs.file(testJarOutputArchive)
outputs.file(upToDateCheckingFile)
doFirst('run migrateSchema command on Jar containg embedded CQL files') {
// '-jar' hack taken from https://github.com/gradle/gradle/issues/1346
// 'javaexec' is used here instead of 'exec' to ensure that the same version of Gradle running the build
// is also used to execute the functional tests.
javaexec {
main = '-jar'
systemProperties += [
'cassandra.storagedir': cassandraStorageDir.get()
]
args = [
testJarOutputArchive.get(),
'migrateSchema'
]
}
}
doLast('write file for up-to-date checking') {
// Explicit lambda casting required in Groovy due to https://github.com/gradle/gradle/issues/4238
final File toWrite = upToDateCheckingFile.map((Transformer<Directory, File>) { it.asFile }).get()
toWrite.write('functional test success')
}
}
tasks.check {
dependsOn(functional, tasks.javadoc)
}
tasks.test {
systemProperties += [
'cassandra.storagedir': project.layout.buildDirectory.dir("$name/cassandra-data-dir").get().asFile
]
}
publishing {
publications {
artifacts(MavenPublication) {
from(components.java)
artifact(sourcesJar.get())
artifact(javadocJar.get())
}
shadow(MavenPublication) {
from(components.java)
artifact(shadowJar)
}
}
}
artifacts {
archives javadocJar, sourcesJar, shadowJar
}
tasks.withType(Sign) {
onlyIf { gradle.taskGraph.hasTask(":uploadArchives") }
}
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://s01.oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'cqlmigrate'
packaging 'jar'
description 'cqlmigrate is a library for performing schema migrations on a cassandra cluster'
url 'https://github.com/sky-uk/cqlmigrate'
scm {
connection 'scm:git:git@github.com:sky-uk/cqlmigrate.git'
developerConnection 'scm:git:git@github.com:sky-uk/cqlmigrate.git'
url 'https://github.com/sky-uk/cqlmigrate.git'
}
licenses {
license {
name 'BSD 3-clause "New" or "Revised" license'
url 'https://opensource.org/licenses/BSD-3-Clause'
}
}
developers {
developer {
id 'adamdougal'
name 'Adam Dougal'
}
developer {
id 'chuckydev'
name 'Charlie McNeill'
}
developer {
id 'tjuszczyk'
name 'Tomasz Juszczyk'
}
developer {
id 'michaelmcfadyensky'
name 'Michael McFadyen'
}
developer {
id 'davidh87'
name 'David Heath'
}
developer {
id 'alangibson01'
name 'Alan Gibson'
}
}
}
}
}
}