/
build.gradle
77 lines (67 loc) · 1.82 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
}
}
plugins {
// Apply the scala plugin to add support for Scala
id 'com.google.protobuf' version '0.8.8'
id 'scala'
}
ext {
scalapbVersion = '0.10.10'
}
repositories {
jcenter()
}
dependencies {
// Use Scala 2.12 in our library project
implementation 'org.scala-lang:scala-library:2.12.8'
// Use Scalatest for testing our library
testImplementation 'junit:junit:4.12'
testImplementation 'org.scalatest:scalatest_2.12:3.0.5'
// Need scala-xml at test runtime
testRuntimeOnly 'org.scala-lang.modules:scala-xml_2.12:1.1.1'
compile "com.thesamet.scalapb:scalapb-runtime_2.12:${scalapbVersion}"
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.7.1'
}
plugins {
scalapb {
artifact = (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem().isWindows()) ?
"com.thesamet.scalapb:protoc-gen-scala:${scalapbVersion}:windows@bat" :
"com.thesamet.scalapb:protoc-gen-scala:${scalapbVersion}:unix@sh"
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
remove java
}
task.plugins {
scalapb {
// add any ScalaPB generator options here. See: https://scalapb.github.io/scalapbc.html#passing-generator-parameters
// option 'flat_package'
}
}
}
}
}
task run(type: JavaExec, dependsOn: classes) {
main = 'scalapb.demo.Demo'
classpath sourceSets.main.runtimeClasspath
classpath configurations.runtime
}
// Add geneated Scala code as a source directory
sourceSets {
main {
scala {
srcDirs "${protobuf.generatedFilesBaseDir}/main/scalapb"
}
}
}