-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle
214 lines (179 loc) · 6.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
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
/**
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id "java"
id "groovy"
id "com.google.cloud.tools.jib" version "3.4.4"
id "com.github.johnrengelman.shadow" version "8.1.1"
id "com.github.harbby.gradle.serviceloader" version "1.1.8"
}
group = "com.google.cloudspannerecosystem"
if (project.hasProperty('tagVersion') && project.tagVersion.trim()) {
project.version = project.tagVersion.trim()
} else {
project.version = "SNAPSHOT"
}
repositories {
mavenCentral()
jcenter()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
// Liquibase <4 uses Liquibase-Package to determine what to scan
jar {
manifest {
attributes(
"Liquibase-Package": "liquibase.ext.spanner"
)
}
}
// Liquibase 4 uses ServiceLoader
serviceLoader {
serviceInterface 'liquibase.database.Database'
serviceInterface 'liquibase.database.DatabaseConnection'
serviceInterface 'liquibase.datatype.LiquibaseDataType'
serviceInterface 'liquibase.sqlgenerator.SqlGenerator'
serviceInterface 'liquibase.change.Change'
serviceInterface 'liquibase.changelog.ChangeLogHistoryService'
serviceInterface 'liquibase.snapshot.SnapshotGenerator'
}
dependencies {
constraints {
implementation("com.google.guava:guava") {
attributes {
attribute(Attribute.of("org.gradle.jvm.environment", String.class), "standard-jvm")
}
}
testImplementation("com.google.guava:guava") {
attributes {
attribute(Attribute.of("org.gradle.jvm.environment", String.class), "standard-jvm")
}
}
}
// Cloud Spanner related
implementation platform('com.google.cloud:libraries-bom:26.50.0')
implementation("com.google.cloud:google-cloud-spanner-jdbc")
// Liquibase Core - needed for testing and docker container
implementation("org.liquibase:liquibase-core:4.30.0")
implementation("org.yaml:snakeyaml:2.3")
implementation("org.apache.commons:commons-lang3:3.17.0")
// Testing
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.3")
testImplementation("org.testcontainers:testcontainers:1.20.3")
testImplementation("net.java.dev.jna:jna:5.15.0")
testImplementation("com.google.truth:truth:1.4.4") {
exclude group: 'com.google.guava', module: 'guava'
}
// For using the Liquibase test harness
testImplementation 'junit:junit:4.13.2'
testImplementation ('org.liquibase:liquibase-test-harness:1.0.10'){
exclude group: 'org.firebirdsql.jdbc', module: 'jaybird'
}
testImplementation('org.apache.groovy:groovy-all:4.0.23') {
exclude module: 'org.codehaus.groovy:groovy-testng'
exclude module: 'org.codehaus.groovy:groovy-swing'
}
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
// For testing runtime
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.11.3")
// For Spanner mock server testing
testImplementation(group: 'com.google.cloud', name: 'google-cloud-spanner', classifier: 'tests')
testImplementation(group: 'com.google.api', name: 'gax-grpc', version: '2.57.0', classifier: 'testlib')
// For Liquibase to work without throwing NoClassDefFound/NoSuchMethodError
testRuntimeOnly("info.picocli:picocli:4.7.6")
}
// Run unit tests (Spanner emulator and mock tests)
test {
// serviceLoaderBuild is necessary for Liquibase to find the extensions
dependsOn "serviceLoaderBuild"
useJUnitPlatform {
excludeTags "integration"
exclude '**/CloudSpannerBaseHarnessSuiteTest*'
exclude '**/CloudSpannerAdvancedHarnessSuiteTest*'
}
}
tasks.register('liquibaseHarnessTest', Test) {
// serviceLoaderBuild is necessary for Liquibase to find the extensions
dependsOn "serviceLoaderBuild"
useJUnitPlatform {
include '**/CloudSpannerBaseHarnessSuiteTest*'
include '**/CloudSpannerAdvancedHarnessSuiteTest*'
include '**/CloudSpannerFoundationalHarnessSuiteTest*'
}
}
// Run integration tests (against live Spanner)
//
// Requires SPANNER_PROJECT and SPANNER_INSTANCE environment variables.
// Also requires GOOGLE_APPLICATION_CREDENTIALS environment variable
// if using a JSON key for authentication.
tasks.register('integrationTest', Test) {
shouldRunAfter "test"
// serviceLoaderBuild is necessary for Liquibase to find the extensions
dependsOn "serviceLoaderBuild"
useJUnitPlatform {
includeTags "integration"
}
}
tasks.withType(Test).configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(8)
}
dependencies {
testImplementation("org.mockito:mockito-core:3.12.4")
}
}
tasks.named('liquibaseHarnessTest', Test).configure {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
}
dependencies {
testImplementation("org.mockito:mockito-core:5.14.1")
}
}
build {
// Build shadowJar during normal build
// This includes all the needed classes for an extension
dependsOn "shadowJar"
}
// Output shadowJar that can be used directly by Liquibase
//
// This contains all Cloud Spanner dependencies.
shadowJar {
dependsOn "test"
archiveBaseName.set("liquibase-spanner")
mergeServiceFiles()
dependencies {
exclude([
dependency("org.liquibase:liquibase-core")
])
}
}
// Output runnable docker container.
//
// The docker container has everything you need to run Liquibase with Spanner.
jib {
from {
image = "gcr.io/distroless/java:8"
}
to {
image = "liquibase-spanner"
}
container {
mainClass = 'liquibase.integration.commandline.Main'
}
}