-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle
164 lines (136 loc) · 4.76 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
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.4"
}
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 {
// If registered in Sonatype after 24 Feb 2021, you must explicitly configure these:
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/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 = "[email protected]"
}}
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.68.1"
def protocVersion = "4.28.3"
def authzedProtoCommit = "v1.38.0"
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}"
implementation "com.google.protobuf:protobuf-java:${protocVersion}"
implementation "io.grpc:grpc-stub:${grpcVersion}"
runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}"
compileOnly "org.apache.tomcat:annotations-api:6.0.53"
}
task validateProtos(type: Exec) {
mkdir bufDir
commandLine("buf", "export", "--exclude-imports", "buf.build/envoyproxy/protoc-gen-validate", "-o", bufDir)
}
task gatewayProtos(type: Exec) {
mkdir bufDir
commandLine("buf", "export", "--exclude-imports", "buf.build/grpc-ecosystem/grpc-gateway", "-o", bufDir)
}
task authzedProtos(type: Exec) {
dependsOn validateProtos
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.26.3"
}
tasks.register('integrationTest', Test) {
useJUnit()
description = 'Runs integration tests.'
group = 'verification'
testClassesDirs = sourceSets.intTest.output.classesDirs
classpath = sourceSets.intTest.runtimeClasspath
shouldRunAfter test
}