-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
179 lines (154 loc) · 5.46 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
// Build script for the Craxiom Network Survey Messaging library
//
// The user must have run the following commands to be able to publish a version to Sonatype Maven Central:
// gradle addCredentials --key sonatypeUsername --value <username>
// gradle addCredentials --key sonatypePassword --value <password>
// gradle addCredentials --key sonatypeKeyPassword --value <password>
//
// From there, execute `./gradlew clean build publish` to build, sign, and upload all the artifacts.
// The final step is to log in to https://oss.sonatype.org/#stagingRepositories to close and release the staging repo
// To generate the python code, you must install the grpc protobuf compiler:
// sudo apt install protobuf-compiler-grpc
plugins {
id 'idea'
id 'java'
id 'maven-publish'
id 'signing'
id 'com.google.protobuf' version '0.9.4'
id 'nu.studer.credentials' version '3.0'
}
group 'com.craxiom'
version "1.6.0"
// Configure the wrapper and ALL distro so IJ has additional context
wrapper {
gradleVersion = '8.9'
distributionType = Wrapper.DistributionType.ALL
}
repositories {
mavenCentral()
}
ext {
grpcVersion = '1.68.0'
protobufVersion = '4.28.2'
protocVersion = protobufVersion
sonatypeUsername = findCredentialValue('Username')
sonatypePassword = findCredentialValue('Password')
ext."signing.password" = findCredentialValue('KeyPassword')
}
dependencies {
implementation "io.grpc:grpc-protobuf:$grpcVersion"
implementation "io.grpc:grpc-stub:$grpcVersion"
implementation "com.google.protobuf:protobuf-java:$protobufVersion"
implementation "javax.annotation:javax.annotation-api:1.3.2"
testImplementation "com.google.protobuf:protobuf-java-util:$protobufVersion"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
}
test {
useJUnitPlatform()
}
static def getPluginPath(name) {
def path = "which grpc_${name}_plugin".execute()
path.waitFor()
path = path.in.text.trim()
return path
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protocVersion"
}
plugins {
grpc_java { artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion" }
//grpc_python { path = getPluginPath("python") }
}
generateProtoTasks {
// adapted from https://github.com/google/protobuf-gradle-plugin/issues/52 to generate python code from within gradle
all()*.builtins {
java {}
//python {}
}
all()*.plugins {
grpc_java { outputSubDir = "java" }
//grpc_python { outputSubDir = "python" }
}
}
}
clean {
delete protobuf.generatedFilesBaseDir
}
task sourceJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc
}
artifacts {
archives javadocJar, sourceJar
}
// Configure publishing to the Sonatype Maven Central repo
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
pom {
name = 'Network Survey Messaging'
description = 'Protobuf and gRPC stubs for sending Wireless Protocol Survey messages\''
url = 'https://github.com/christianrowlands/network-survey-messaging'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://github.com/christianrowlands/network-survey-messaging/blob/master/LICENSE'
}
}
developers {
developer {
id = 'christianrowlands'
name = 'Christian Rowlands'
email = '[email protected]'
}
}
scm {
url = 'https://github.com/christianrowlands/network-survey-messaging'
connection = 'scm:git:git://github.com/christianrowlands/network-survey-messaging.git'
developerConnection = 'scm:git:ssh://[email protected]:christianrowlands/network-survey-messaging.git'
}
issueManagement {
system = 'GitHub'
url = 'https://github.com/christianrowlands/network-survey-messaging/issues'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username sonatypeUsername
password sonatypePassword
}
}
mavenLocal()
}
}
signing {
sign publishing.publications
}
/**
* Try to locate a credential value (username or password) in the credentials store.
*
* @param value The suffix to use for the credential lookup key. It will be appended to "sonatype".
* @return The credential value if located.
*/
private String findCredentialValue(String value) {
return project.credentials.forKey("sonatype$value")
}