forked from authzed/authzed-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
193 lines (164 loc) · 6.25 KB
/
build.gradle
File metadata and controls
193 lines (164 loc) · 6.25 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
191
192
193
plugins {
id "java-library"
id "maven-publish"
id "signing"
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
id "com.google.protobuf" version "0.9.5"
}
repositories {
// The Google mirror is less flaky than mavenCentral()
maven { url "https://maven-central.storage-download.googleapis.com/maven2/" }
mavenCentral()
mavenLocal()
}
group = "com.authzed.api"
version = findProperty("release") ?: "0.0.0-SNAPSHOT"
nexusPublishing {
repositories {
sonatype {
// Docs here:
// https://github.com/gradle-nexus/publish-plugin?tab=readme-ov-file#publishing-to-maven-central-via-sonatype-central
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
}}}
publishing {
publications { authzed(MavenPublication) {
from components.java
pom {
name = "authzed"
description = "Authzed client library for Java"
url = "https://github.com/authzed/authzed-java"
licenses { license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}}
developers { developer {
id = "jzelinskie"
name = "Jimmy Zelinskie"
email = "jimmy@authzed.com"
}}
scm {
connection = "scm:git:git://github.com/authzed/authzed-java.git"
developerConnection = "scm:git:ssh://github.com:authzed/authzed-java.git"
url = "https://github.com/authzed/authzed-java/tree/master"
}
}
}}
repositories { maven {
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
def ossrhUsername = findProperty("sonatypeUsername")
def ossrhPassword = findProperty("sonatypePassword")
name = "authzed"
url = project.hasProperty("release") ? releasesRepoUrl : snapshotsRepoUrl
}}
}
signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.authzed
}
java {
withJavadocJar()
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.sourcesJar {
// This is necessary to keep gradle from barking at you
// about an implicit dependency between these two tasks.
dependsOn tasks.compileJava
}
// All it does is complain about generated code.
javadoc { options.addStringOption('Xdoclint:none', '-quiet') }
def grpcVersion = "1.75.0"
def protocVersion = "4.32.1"
def authzedProtoCommit = "v1.45.4"
def bufDir = "${buildDir}/buf"
def protocPlatformTag = project.findProperty('protoc_platform') ? ":${protoc_platform}" : ""
sourceSets { main {
proto { srcDir bufDir }
java { srcDir "$buildDir/generated" }
java { srcDir "$buildDir/src" }
}}
dependencies {
implementation("io.grpc:grpc-protobuf:${grpcVersion}") {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'com.google.api.grpc', module: 'proto-google-common-protos'
}
implementation "io.grpc:grpc-stub:${grpcVersion}"
runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}"
compileOnly "org.apache.tomcat:annotations-api:6.0.53"
implementation("build.buf:protovalidate:1.0.0") {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'com.google.protobuf', module: 'protobuf-java-util'
exclude group: 'com.google.code.gson', module: 'gson'
exclude group: 'com.google.re2j', module: 're2j'
exclude group: 'com.google.code.findbugs', module: 'annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
// In the future this can probably be removed in favor of "protovalidate"
// See https://buf.build/blog/protoc-gen-validate-v1-and-v2
implementation("build.buf.protoc-gen-validate:pgv-java-stub:1.2.1") {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'com.google.protobuf', module: 'protobuf-java-util'
exclude group: 'com.google.code.gson', module: 'gson'
exclude group: 'com.google.re2j', module: 're2j'
}
api "com.google.protobuf:protobuf-java:${protocVersion}"
implementation("com.google.protobuf:protobuf-java-util:${protocVersion}") {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'com.google.code.gson', module: 'gson'
}
implementation("com.google.api.grpc:proto-google-common-protos:2.61.3") {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
implementation "com.google.code.gson:gson:2.11.0"
implementation "com.google.re2j:re2j:1.8"
implementation "com.google.code.findbugs:jsr305:3.0.2"
}
// There is no pre-packaged JAR available that contains the gRPC Gateway proto files
task gatewayProtos(type: Exec) {
mkdir bufDir
commandLine("buf", "export", "--exclude-imports", "buf.build/grpc-ecosystem/grpc-gateway", "-o", bufDir)
}
task authzedProtos(type: Exec) {
dependsOn gatewayProtos
commandLine("buf", "export", "--exclude-imports", "buf.build/authzed/api:${authzedProtoCommit}", "-o", bufDir)
}
protobuf {
protoc { artifact = "com.google.protobuf:protoc:${protocVersion}${protocPlatformTag}" }
plugins { grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}${protocPlatformTag}" } }
generateProtoTasks {
ofSourceSet("main").each { task -> task.dependsOn authzedProtos }
all()*.plugins { grpc {} }
}
}
tasks.named("jar") { manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": project.version)
}}
sourceSets {
intTest {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
configurations {
intTestImplementation.extendsFrom implementation
intTestRuntimeOnly.extendsFrom runtimeOnly
}
// Test things
dependencies {
intTestImplementation "junit:junit:4.13.2"
intTestImplementation "org.assertj:assertj-core:3.27.6"
}
tasks.register('integrationTest', Test) {
useJUnit()
description = 'Runs integration tests.'
group = 'verification'
testClassesDirs = sourceSets.intTest.output.classesDirs
classpath = sourceSets.intTest.runtimeClasspath
shouldRunAfter test
}