-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
168 lines (154 loc) · 5.09 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
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id "com.diffplug.spotless" version "6.13.0"
}
group = 'cloud.eppo'
version = '3.7.1-SNAPSHOT'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
implementation 'com.github.zafarkhaja:java-semver:0.10.2'
implementation "com.squareup.okhttp3:okhttp:4.12.0"
// For LRU and expiring maps
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'org.slf4j:slf4j-api:2.0.16'
testImplementation 'org.slf4j:slf4j-simple:2.0.16'
testImplementation platform('org.junit:junit-bom:5.11.4')
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.skyscreamer:jsonassert:1.5.3'
testImplementation 'commons-io:commons-io:2.18.0'
testImplementation 'com.google.truth:truth:1.4.4'
testImplementation ('org.mockito:mockito-core:4.11.0') {
exclude group: 'net.bytebuddy', module: 'byte-buddy' // mockito 4's version doesn't work with Java 21
}
testImplementation 'net.bytebuddy:byte-buddy:1.17.0' // Use the latest available version
testImplementation 'org.mockito:mockito-inline:4.11.0'
}
test {
useJUnitPlatform()
testLogging {
events "started", "passed", "skipped", "failed"
exceptionFormat "full"
showExceptions true
showCauses true
showStackTraces true
}
}
spotless {
ratchetFrom 'origin/main'
format 'misc', {
target '*.gradle', '.gitattributes', '.gitignore'
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
java {
googleJavaFormat('1.7')
formatAnnotations()
}
}
tasks.register('testJar', Jar) {
archiveClassifier.set('tests')
from sourceSets.test.output
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'sdk-common-jvm'
from components.java
artifact testJar // Include the test-jar in the published artifacts
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Eppo JVM SDK shared library'
description = 'Eppo SDK for JVM shared library'
url = 'https://github.com/Eppo-exp/sdk-common-jvm'
licenses {
license {
name = 'MIT License'
url = 'http://www.opensource.org/licenses/mit-license.php'
}
}
developers {
developer {
name = 'Eppo'
email = 'https://geteppo.com'
}
}
scm {
connection = 'scm:git:git://example.com/my-library.git'
developerConnection = 'scm:git:ssh://example.com/my-library.git'
url = 'http://example.com/my-library/'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = project.properties.containsKey("ossrhUsername") ? project.properties["ossrhUsername"] : ""
password = project.properties.containsKey("ossrhPassword") ? project.properties["ossrhPassword"] : ""
}
}
}
}
// Custom task to ensure we can conditionally publish either a release or snapshot artifact
// based on a command line switch. See github workflow files for more details on usage.
tasks.register('checkVersion') {
doLast {
if (!project.hasProperty('release') && !project.hasProperty('snapshot')) {
throw new GradleException("You must specify either -Prelease or -Psnapshot")
}
if (project.hasProperty('release') && project.version.endsWith('SNAPSHOT')) {
throw new GradleException("You cannot specify -Prelease with a SNAPSHOT version")
}
if (project.hasProperty('snapshot') && !project.version.endsWith('SNAPSHOT')) {
throw new GradleException("You cannot specify -Psnapshot with a non-SNAPSHOT version")
}
project.ext.shouldPublish = true
}
}
// Ensure checkVersion runs before publishing
tasks.named('publish').configure {
dependsOn checkVersion
}
// Conditionally enable or disable publishing tasks
tasks.withType(PublishToMavenRepository).configureEach {
onlyIf {
project.ext.has('shouldPublish') && project.ext.shouldPublish
}
}
if (!project.gradle.startParameter.taskNames.contains('publishToMavenLocal')) {
signing {
sign publishing.publications.mavenJava
if (System.env['CI']) {
useInMemoryPgpKeys(System.env.GPG_PRIVATE_KEY, System.env.GPG_PASSPHRASE)
}
}
}
javadoc {
failOnError = false
options.addStringOption('Xdoclint:none', '-quiet')
options.addBooleanOption('failOnError', false)
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}