-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle.kts
165 lines (146 loc) · 5.67 KB
/
build.gradle.kts
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
import de.undercouch.gradle.tasks.download.Download
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
val deployerJars by configurations.creating
group = "org.utplsql"
val mavenArtifactId = "java-api"
version = "3.1.6"
val coverageResourcesVersion = "1.0.1"
val ojdbcVersion = "12.2.0.1"
plugins {
`java-library`
`maven-publish`
maven
id("de.undercouch.download") version "3.4.3"
}
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 {
maven {
url = uri("https://www.oracle.com/content/secure/maven/content")
credentials {
// you may set this properties using gradle.properties file in the root of the project or in your GRADLE_HOME
username = if (project.hasProperty("ORACLE_OTN_USER")) project.property("ORACLE_OTN_USER") as String? else System.getenv("ORACLE_OTN_USER")
password = if (project.hasProperty("ORACLE_OTN_PASSWORD")) project.property("ORACLE_OTN_PASSWORD") as String? else System.getenv("ORACLE_OTN_PASSWORD")
}
}
mavenCentral()
}
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.25")
implementation("com.oracle.jdbc:ojdbc8:$ojdbcVersion") {
exclude(group = "com.oracle.jdbc")
}
implementation("com.oracle.jdbc:orai18n:$ojdbcVersion")
// Use Jupiter test framework
testImplementation("org.junit.jupiter:junit-jupiter:5.4.0")
testImplementation("org.hamcrest:hamcrest:2.1")
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
}
}
val intTest = create<Test>("intTest") {
dependsOn(test)
doFirst {
environment("DB_URL", System.getenv("DB_URL") ?: "localhost:1521/XE")
environment("DB_USER", System.getenv("DB_USER") ?: "app")
environment("DB_PASS", 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)
}
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"])
}
}
}