-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
190 lines (165 loc) · 6.44 KB
/
build.gradle.kts
File metadata and controls
190 lines (165 loc) · 6.44 KB
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
import de.undercouch.gradle.tasks.download.Download
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
val tag = System.getenv("CI_TAG")?.replaceFirst("^v".toRegex(), "")
group = "org.utplsql"
val mavenArtifactId = "java-api"
val baseVersion = "3.1.9-SNAPSHOT"
// if build is on tag like 3.1.7 or v3.1.7 then use tag as version replacing leading "v"
version = if (tag != null && "^[0-9.]+$".toRegex().matches(tag)) tag else baseVersion
val coverageResourcesVersion = "1.0.1"
val ojdbcVersion = "19.3.0.0"
val junitVersion = "5.5.2"
val deployerJars by configurations.creating
plugins {
`java-library`
`maven-publish`
maven
id("de.undercouch.download") version "4.0.0"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
// In this section you declare where to find the dependencies of your project
repositories {
mavenCentral()
jcenter()
}
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api("com.google.code.findbugs:jsr305:3.0.2")
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation("org.slf4j:slf4j-api:1.7.36")
implementation("com.oracle.database.jdbc:ojdbc8:$ojdbcVersion") {
exclude(group = "com.oracle.database.jdbc", module = "ucp")
}
implementation("com.oracle.database.nls:orai18n:$ojdbcVersion")
// Use Jupiter test framework
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
testImplementation("org.hamcrest:hamcrest:2.1")
// Mockito
testImplementation("org.mockito:mockito-core:3.0.0")
// deployer for packagecloud
deployerJars("io.packagecloud.maven.wagon:maven-packagecloud-wagon:0.0.6")
}
tasks {
test {
useJUnitPlatform()
exclude("**/*IT.class")
testLogging {
events("passed", "skipped", "failed")
exceptionFormat = TestExceptionFormat.FULL
showStackTraces = true
}
}
// run tests using compiled jar + dependencies and tests classes
val binaryTest = create<Test>("binaryTest") {
dependsOn(jar, testClasses)
doFirst {
classpath = project.files("$buildDir/libs/java-api-$version.jar", "$buildDir/classes/java/test", configurations.testRuntimeClasspath)
testClassesDirs = sourceSets.getByName("test").output.classesDirs
}
useJUnitPlatform {
includeTags("binary")
}
testLogging {
events("passed", "skipped", "failed")
exceptionFormat = TestExceptionFormat.FULL
showStackTraces = true
showStandardStreams = true
}
}
val intTest = create<Test>("intTest") {
dependsOn(test)
doFirst {
environment("DB_URL", (project.findProperty("DB_URL") as String?) ?: System.getenv("DB_URL")
?: "localhost:1521/XE")
environment("DB_USER", (project.findProperty("DB_USER") as String?) ?: System.getenv("DB_USER") ?: "app")
environment("DB_PASS", (project.findProperty("DB_PASS") as String?) ?: System.getenv("DB_PASS") ?: "app")
}
useJUnitPlatform()
include("**/*IT.class")
testLogging {
events("passed", "skipped", "failed")
exceptionFormat = TestExceptionFormat.FULL
showStackTraces = true
showStandardStreams = true
}
}
// add integration tests to the whole check
named("check") {
dependsOn(intTest)
dependsOn(binaryTest)
}
val coverageResourcesDirectory = "${project.buildDir}/resources/main/CoverageHTMLReporter"
val coverageResourcesZip = "${project.buildDir}/utPLSQL-coverage-html-$coverageResourcesVersion.zip"
// download Coverage Resources from web
val downloadResources = create<Download>("downloadCoverageResources") {
src("https://codeload.github.com/utPLSQL/utPLSQL-coverage-html/zip/$coverageResourcesVersion")
dest(File(coverageResourcesZip))
overwrite(true)
}
withType<ProcessResources> {
dependsOn(downloadResources)
val properties = project.properties.toMutableMap()
properties.putIfAbsent("travisBuildNumber", System.getenv("TRAVIS_BUILD_NUMBER") ?: "local")
expand(properties)
doLast {
copy {
// extract assets folder only from downloaded archive
// https://github.com/gradle/gradle/pull/8494
from(zipTree(coverageResourcesZip)) {
include("*/assets/**")
eachFile {
relativePath = RelativePath(true, *relativePath.segments.drop(2).toTypedArray()) // <2>
}
includeEmptyDirs = false
}
into(coverageResourcesDirectory)
}
}
}
withType<Jar> {
dependsOn("generatePomFileForMavenPublication")
manifest {
attributes(
"Built-By" to System.getProperty("user.name"),
"Created-By" to "Gradle ${gradle.gradleVersion}",
"Build-Jdk" to "${System.getProperty("os.name")} ${System.getProperty("os.arch")} ${System.getProperty("os.version")}"
)
}
into("META-INF/maven/${project.group}/$mavenArtifactId") {
from("$buildDir/publications/maven")
rename(".*", "pom.xml")
}
archiveBaseName.set("java-api")
}
named<Upload>("uploadArchives") {
repositories.withGroovyBuilder {
"mavenDeployer" {
setProperty("configuration", deployerJars)
"repository"("url" to "packagecloud+https://packagecloud.io/utPLSQL/utPLSQL-java-api") {
"authentication"("password" to System.getenv("PACKAGECLOUD_TOKEN"))
}
}
}
}
}
publishing {
publications {
create<MavenPublication>("maven") {
artifactId = mavenArtifactId
pom {
name.set("utPLSQL-java-api")
url.set("https://github.com/utPLSQL/utPLSQL-java-api")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
from(components["java"])
}
}
}