-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
build.gradle
188 lines (164 loc) · 6.25 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
plugins {
id 'java'
id 'signing'
id 'maven-publish'
id 'io.github.gradle-nexus.publish-plugin' version "${nexusPluginVersion}"
id 'com.github.johnrengelman.shadow' version "${shadowJarPluginVersion}"
id 'org.hidetake.swagger.generator' version '2.19.2'
}
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
apply plugin: DownloadSpecsPlugin
repositories {
mavenCentral()
}
group = 'org.typesense'
version = '1.1.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8
jar {
manifest {
attributes(
"Main-Class": "org.typesense.api.Client",
"Multi-Release": "true"
)
}
exclude "META-INF/DEPENDENCIES"
}
tasks.withType(Test) {
testLogging {
// set options for log level LIFECYCLE
events TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT
exceptionFormat TestExceptionFormat.FULL
showExceptions true
showCauses true
showStackTraces true
// set options for log level DEBUG and INFO
debug {
events TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT
exceptionFormat TestExceptionFormat.FULL
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}
sourceSets {
integrationTest {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
java.srcDir file('src/integration-test/java')
resources.srcDir file('src/integration-test/resources')
}
}
configurations {
integrationTestImplementation.extendsFrom implementation
integrationTestRuntimeOnly.extendsFrom runtimeOnly
}
java {
withJavadocJar()
withSourcesJar()
}
tasks.register('integrationTest', Test) {
description = 'Runs integration tests (assumes running Docker image or local server)'
group = 'verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
shouldRunAfter test
}
check.dependsOn integrationTest
dependencies {
implementation "javax.xml.bind:jaxb-api:${javaxXmlBindVersion}"
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonCoreVersion}"
implementation "io.swagger.core.v3:swagger-annotations:${swaggerCoreV3Version}"
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
implementation "com.squareup.okhttp3:okhttp:${okhttp3Version}"
implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}"
testImplementation "org.mockito:mockito-core:${mokitoVerion}"
testImplementation "org.mockito:mockito-junit-jupiter:${mokitoVerion}"
testImplementation "org.hamcrest:hamcrest-all:${hamcrestVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}"
integrationTestImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}"
integrationTestImplementation "org.hamcrest:hamcrest-all:${hamcrestVersion}"
integrationTestRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}"
swaggerCodegen 'io.swagger.codegen.v3:swagger-codegen-cli:3.0.36'
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
swaggerSources {
typesense {
inputFile = file("$buildDir/openapi.yml")
code {
language = "java"
configFile = file("swagger-config.json")
components = ['models']
}
}
}
swaggerSources.typesense.code.dependsOn downloadApiSpec
sourcesJar.dependsOn swaggerSources.typesense.code
compileJava.dependsOn swaggerSources.typesense.code
sourceSets.main.java.srcDir "${swaggerSources.typesense.code.outputDir}/src/main/java"
sourceSets.main.resources.srcDir "${swaggerSources.typesense.code.outputDir}/src/main/resources"
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = findProperty("ossrhToken") as String
password = findProperty("ossrhTokenPassword") as String
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
name = 'typesense-java'
description = 'Typesense Java Client'
url = 'https://github.com/typesense/typesense-java'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
}
}
developers {
developer {
id = 'typesense'
name = 'Typesense'
}
}
scm {
url = 'https://github.com/typesense/typesense-java'
connection = 'scm:git://github.com/typesense/typesense-java.git'
developerConnection = 'scm:git://github.com/typesense/typesense-java.git'
}
}
}
}
}
if (project.hasProperty("signing.keyId")) {
signing {
sign publishing.publications.mavenJava
}
}