-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.gradle
344 lines (315 loc) · 11.8 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
mavenCentral()
maven {
url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies'
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_version"
}
}
allprojects {
group 'com.github.cretz.pbandk'
version '0.3.0'
repositories {
mavenCentral()
}
}
project(':runtime:runtime-common') {
apply plugin: 'kotlin-platform-common'
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
}
task generateWellKnownTypes {
dependsOn ':protoc-gen-kotlin:protoc-gen-kotlin-jvm:installDist'
doFirst {
def protocPath = System.getProperty('protoc.path')
if (protocPath == null) throw new InvalidUserDataException('System property protoc.path must be set')
runProtoGen(Paths.get(protocPath, 'include').toString(), 'src/main/kotlin', 'pbandk.wkt', 'debug', 'google/protobuf')
}
}
publishSettings(project, 'pbandk-runtime-common', 'Common library for PBAndK Protobuf code')
}
project(':runtime:runtime-js') {
apply plugin: 'kotlin-platform-js'
dependencies {
expectedBy project(':runtime:runtime-common')
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
}
compileKotlin2Js {
kotlinOptions.moduleKind = 'commonjs'
}
publishSettings(project, 'pbandk-runtime-js', 'JS library for PBAndK Protobuf code')
}
project(':runtime:runtime-jvm') {
apply plugin: 'kotlin-platform-jvm'
sourceCompatibility = '1.6'
compileKotlin {
kotlinOptions.jvmTarget = '1.6'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '1.6'
}
dependencies {
expectedBy project(':runtime:runtime-common')
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.google.protobuf:protobuf-java:3.6.1'
testCompile 'junit:junit:4.12'
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}
test {
testLogging {
outputs.upToDateWhen {false}
showStandardStreams = true
exceptionFormat = 'full'
events 'passed', 'skipped', 'failed'
}
}
task generateTestTypes {
dependsOn ':protoc-gen-kotlin:protoc-gen-kotlin-jvm:installDist'
doFirst {
runProtoGen('src/test/proto', 'src/test/kotlin', 'pbandk.testpb', 'debug', 'pbandk/testpb')
}
doFirst {
exec {
commandLine('protoc', '-Isrc/test/proto', '--java_out=src/test/java', 'src/test/proto/pbandk/testpb/test.proto')
}
}
}
publishSettings(project, 'pbandk-runtime-jvm', 'JVM library for PBAndK Protobuf code')
}
project(':runtime:runtime-native') {
apply plugin: 'konan'
konanArtifacts {
library('pbandk') {
enableMultiplatform true
}
}
dependencies {
expectedBy project(':runtime:runtime-common')
}
}
project(':protoc-gen-kotlin:protoc-gen-kotlin-common') {
apply plugin: 'kotlin-platform-common'
dependencies {
compile project(':runtime:runtime-common')
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
}
task generateProto {
dependsOn ':protoc-gen-kotlin:protoc-gen-kotlin-jvm:installDist'
doFirst {
runProtoGen('src/main/proto', 'src/main/kotlin', 'pbandk.gen.pb', 'debug')
}
}
publishSettings(project, 'protoc-gen-kotlin-common', 'Common library for PBAndK Protobuf code generator')
}
project(':protoc-gen-kotlin:protoc-gen-kotlin-jvm') {
apply plugin: 'kotlin-platform-jvm'
apply plugin: 'application'
sourceCompatibility = '1.8'
compileKotlin {
kotlinOptions.jvmTarget = '1.8'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '1.8'
}
mainClassName = 'pbandk.gen.MainKt'
applicationName = 'protoc-gen-kotlin'
dependencies {
expectedBy project(':protoc-gen-kotlin:protoc-gen-kotlin-common')
compile project(':runtime:runtime-jvm')
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile 'junit:junit:4.12'
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}
test {
testLogging {
outputs.upToDateWhen {false}
showStandardStreams = true
exceptionFormat = 'full'
events 'passed', 'skipped', 'failed'
}
}
publishSettings(project, 'protoc-gen-kotlin-jvm', 'JVM library for PBAndK Protobuf code generator')
}
project(':protoc-gen-kotlin:protoc-gen-kotlin-native') {
apply plugin: 'konan'
konanArtifacts {
program('protoc-gen-kotlin-native') {
enableMultiplatform true
libraries {
allLibrariesFrom project(':runtime:runtime-native')
}
}
}
dependencies {
expectedBy project(':protoc-gen-kotlin:protoc-gen-kotlin-common')
}
}
project(':conformance:conformance-common') {
apply plugin: 'kotlin-platform-common'
dependencies {
compile project(':runtime:runtime-common')
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
}
task generateProto {
dependsOn ':protoc-gen-kotlin:protoc-gen-kotlin-jvm:installDist'
doFirst {
runProtoGen('src/main/proto', 'src/main/kotlin', 'pbandk.conformance.pb', 'debug')
}
}
}
project(':conformance:conformance-js') {
apply plugin: 'kotlin-platform-js'
dependencies {
expectedBy project(':conformance:conformance-common')
compile project(':runtime:runtime-js')
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
}
compileKotlin2Js {
kotlinOptions.moduleKind = 'commonjs'
}
}
project(':conformance:conformance-jvm') {
apply plugin: 'kotlin-platform-jvm'
apply plugin: 'application'
sourceCompatibility = '1.8'
compileKotlin {
kotlinOptions.jvmTarget = '1.8'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '1.8'
}
mainClassName = 'pbandk.conformance.MainKt'
dependencies {
expectedBy project(':conformance:conformance-common')
compile project(':runtime:runtime-jvm')
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile 'junit:junit:4.12'
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}
test {
testLogging {
outputs.upToDateWhen {false}
showStandardStreams = true
exceptionFormat = 'full'
events 'passed', 'skipped', 'failed'
}
}
}
project(':conformance:conformance-native') {
apply plugin: 'konan'
konanArtifacts {
program('pbandk-conformance') {
enableMultiplatform true
libraries {
allLibrariesFrom project(':runtime:runtime-native')
}
}
}
dependencies {
expectedBy project(':conformance:conformance-common')
}
}
import java.nio.file.Paths
allprojects {
ext.runProtoGen = { inPath, outPath, kotlinPackage = null, logLevel = null, inSubPath = null ->
// Build CLI args
def args = ['protoc']
args << '--kotlin_out='
if (kotlinPackage != null) args[-1] += "kotlin_package=$kotlinPackage,"
if (logLevel != null) args[-1] += "log=$logLevel,"
args[-1] += 'empty_arg:' + Paths.get(outPath)
args << '--plugin=protoc-gen-kotlin=' +
Paths.get(project.rootDir.toString(), 'protoc-gen-kotlin/protoc-gen-kotlin-jvm/build/install/protoc-gen-kotlin/bin/protoc-gen-kotlin')
if (System.properties['os.name'].toLowerCase().contains('windows')) args[-1] += '.bat'
def includePath = Paths.get(inPath)
if (!includePath.absolute) includePath = Paths.get(project.projectDir.toString(), inPath)
args << '-I' << includePath
def filePath = includePath
if (inSubPath != null) filePath = includePath.resolve(inSubPath)
args += filePath.toFile().listFiles().findAll {
it.isFile() && it.toString().endsWith('.proto')
}
// Run it
exec { commandLine(*args) }
}
}
def publishSettings(project, projectName, projectDescription) {
project.with {
if (!project.hasProperty('ossrhUsername')) return
apply plugin: 'maven'
apply plugin: 'signing'
archivesBaseName = projectName
task packageSources(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
if (project.name.endsWith('-jvm') || project.name.endsWith('-js')) {
duplicatesStrategy = 'exclude'
def commonProject = project.parent.subprojects.find { it.name.endsWith('-common') }
from(sourceSets.main.allSource + commonProject.sourceSets.main.allSource)
}
}
task packageJavadoc(type: Jar) {
// Empty to satisfy Sonatype's javadoc.jar requirement
classifier 'javadoc'
}
artifacts {
archives packageSources, packageJavadoc
}
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name projectName
packaging 'jar'
description projectDescription
url 'https://github.com/cretz/pbandk'
scm {
connection 'scm:git:[email protected]:cretz/pbandk.git'
developerConnection 'scm:git:[email protected]:cretz/pbandk.git'
url '[email protected]:cretz/pbandk.git'
}
licenses {
license {
name 'MIT License'
url 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id 'cretz'
name 'Chad Retz'
url 'https://github.com/cretz'
}
}
}
}
}
}
}
}