forked from cretz/pb-and-k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
62 lines (57 loc) · 2.17 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
buildscript {
ext.kotlin_version = '1.2.60'
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:0.7'
}
}
allprojects {
group 'com.github.cretz.pbandk'
version '0.3.0-toast-4-SNAPSHOT'
repositories {
mavenCentral()
mavenLocal()
}
apply plugin: 'maven-publish'
publishing {
repositories {
maven {
url = "https://artifactory.eng.toasttab.com/artifactory/libs-${version.endsWith('-SNAPSHOT') ? 'snapshot' : 'release'}-local"
credentials {
username = project.properties.getOrDefault("artifactory_user", "")
password = project.properties.getOrDefault("artifactory_password", "")
}
}
}
}
}
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) }
}
}