-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
162 lines (135 loc) · 5.73 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
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/6.7/userguide/building_java_projects.html
*/
plugins {
id 'java'
id 'groovy'
id 'application'
id 'org.graalvm.buildtools.native' version '0.9.28'
id 'maven-publish'
}
// read the version from the `VERSION` file
version = new File(rootDir,'VERSION').text.trim()
group = 'io.seqera'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
compileJava {
// Set binary compatibility for Java compiler to 11 (worth checking to update this also)
options.release.set(11)
}
}
repositories {
mavenCentral()
}
def nativeCliTest = sourceSets.create('nativeCliTest')
configurations[nativeCliTest.implementationConfigurationName].extendsFrom(configurations.testImplementation)
configurations[nativeCliTest.runtimeOnlyConfigurationName].extendsFrom(configurations.testRuntimeOnly)
dependencies {
// This dependency is used by the application.
implementation "ch.qos.logback:logback-classic:1.2.3"
runtimeOnly 'mysql:mysql-connector-java:8.0.22'
runtimeOnly 'com.h2database:h2:1.4.200'
runtimeOnly 'mysql:mysql-connector-java:8.0.28'
runtimeOnly 'org.xerial:sqlite-jdbc:3.42.0.0'
runtimeOnly("org.postgresql:postgresql:42.7.3")
implementation 'info.picocli:picocli:4.6.3'
annotationProcessor 'info.picocli:picocli-codegen:4.6.3'
implementation "org.codehaus.groovy:groovy:3.0.9"
implementation "org.codehaus.groovy:groovy-sql:3.0.9"
// Use the latest Groovy version for Spock testing
testImplementation "org.codehaus.groovy:groovy:3.0.9"
testImplementation "org.codehaus.groovy:groovy-nio:3.0.9"
testImplementation platform("org.spockframework:spock-bom:2.1-groovy-3.0")
testImplementation "org.spockframework:spock-core"
testImplementation "org.spockframework:spock-junit4" // you can remove this if your code does not rely on old JUnit 4 rules
testImplementation 'junit:junit:4.13'
testImplementation "org.testcontainers:testcontainers:1.20.1"
testImplementation "org.testcontainers:mysql:1.16.3"
testImplementation "org.testcontainers:spock:1.16.3"
testImplementation 'org.testcontainers:postgresql:1.16.3'
testImplementation("org.postgresql:postgresql:42.7.3")
// Dummy library containing some migration files among their resources for testing purposes
testImplementation files("libs/jar-with-resources.jar")
nativeCliTestImplementation project
nativeCliTestImplementation "org.codehaus.groovy:groovy-sql:3.0.9"
}
test {
useJUnitPlatform()
}
application {
// Define the main class for the application.
mainClass = 'io.seqera.migtool.App'
applicationDefaultJvmArgs = ["-agentlib:native-image-agent=config-merge-dir=conf/"]
}
ext.aws_access_key_id = project.findProperty('aws_access_key_id') ?: System.getenv('AWS_ACCESS_KEY_ID')
ext.aws_secret_access_key = project.findProperty('aws_secret_access_key') ?: System.getenv('AWS_SECRET_ACCESS_KEY')
ext.publishRepoUrl = project.findProperty('publish_repo_url') ?: System.getenv('PUBLISH_REPO_URL') ?: ( version.endsWith('-SNAPSHOT') ? "s3://maven.seqera.io/snapshots" : "s3://maven.seqera.io/releases" )
// Add sources to JARs.
jar {
from sourceSets.main.allSource
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
url = publishRepoUrl
credentials(AwsCredentials) {
// keys are defined in the `gradle.properties` file
accessKey aws_access_key_id
secretKey aws_secret_access_key
}
}
}
}
/** Define a duplication strategy for `jar` tasks.
* Prevents error "Entry <filename> is a duplicate but no duplicate handling strategy has been set"
* since Gradle 7 (https://github.com/gradle/gradle/issues/17236).
*/
tasks.withType(Jar) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
graalvmNative {
binaries {
main {
imageName = 'migtool'
mainClass = 'io.seqera.migtool.App'
configurationFileDirectories.from(file('conf'))
buildArgs(org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem.isLinux() ? ['--static', ] : [])
buildArgs.add('--allow-incomplete-classpath')
buildArgs.add('--report-unsupported-elements-at-runtime')
buildArgs.add('--initialize-at-run-time=sun.nio.ch.WindowsAsynchronousFileChannelImpl$DefaultIocpHolder')
buildArgs.add('-H:+AddAllCharsets')
buildArgs.add('-H:EnableURLProtocols=https,http')
buildArgs.add('-H:+ReportExceptionStackTraces')
buildArgs.add('-H:-CheckToolchain')
buildArgs.add('-H:IncludeResources=.*/TlsSettings.properties$')
buildArgs.add('-H:+StaticExecutableWithDynamicLibC')
buildArgs.add('-H:+PrintClassInitialization')
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
}
}
def nativeCliTestTask = tasks.register('nativeCliTest', Test) {
description = 'Runs nativeCli tests.'
group = 'verification'
useJUnitPlatform()
testClassesDirs = nativeCliTest.output.classesDirs
classpath = configurations[nativeCliTest.runtimeClasspathConfigurationName] + nativeCliTest.output
dependsOn nativeCompile
environment 'NATIVE_BINARY_PATH', "$buildDir/native/nativeCompile/migtool"
}
tasks.named('check') {
dependsOn(nativeCliTestTask)
}