Skip to content

Instantly share code, notes, and snippets.

@RdeWilde
Last active August 13, 2019 20:08
Show Gist options
  • Save RdeWilde/ec3a5c9432004579643a47ed5fee3397 to your computer and use it in GitHub Desktop.
Save RdeWilde/ec3a5c9432004579643a47ed5fee3397 to your computer and use it in GitHub Desktop.
Partial gradle build file
//...
group = "sample"
version = "0.0.1"
val kotlinMultiplatformVersion = "1.3.40"
//...
val protobufPluginVersion = "0.8.10"
//...
project.extensions.add("protobuf", ProtobufConfigurator(project, null))
buildscript {
repositories {
//...
}
dependencies {
classpath("com.google.protobuf:protobuf-gradle-plugin:+")
classpath(kotlin("gradle-plugin", "1.3.40"))
}
}
apply {
plugin<ProtobufPlugin>()
}
allprojects {
repositories {
//...
}
}
repositories {
//...
}
dependencies {
implementation("com.google.protobuf:protobuf-java:3.6.1")
//...
if (JavaVersion.current().isJava9Compatible) {
implementation("javax.annotation:javax.annotation-api:+")
}
}
plugins {
//...
id("kotlin-multiplatform") version "1.3.40"
id("com.google.protobuf") version "0.8.10"
//...
}
//...
tasks.withType<KotlinCompile> {
dependsOn.add("generateProto")
//...
}
//...
kotlin {
targets.add(presets["jvm"].createTarget("jvm"))
//...
sourceSets.apply {
val commonMain = getByName("commonMain") {
dependencies {
//...
implementation("com.google.protobuf:protobuf-gradle-plugin:0.8.10")
implementation("com.google.protobuf:protobuf-java:3.6.1")
//...
}
}
val commonTest = getByName("commonTest") {
dependencies {
//...
}
}
val allJvmMain = create("allJvmMain") {
//...
}
configure(listOf(getByName("jvmMain")/*, getByName("androidMain")*/)) {
dependsOn(allJvmMain)
}
//...
}
}
configure<ProtobufConfigurator> {
generatedFilesBaseDir = "$projectDir/src/"
protoc {
artifact = "com.google.protobuf:protoc:3.9.0"
}
plugins {
id("javalite") {
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
}
id("krotoPlus") {
// artifact = "com.github.marcoferrer.krotoplus:protoc-gen-kroto-plus:+:jvm8@jar"
path = "/home/robert/projects/kroto-plus/protoc-gen-kroto-plus/build/libs/protoc-gen-kroto-plus-0.4.0-jvm8.jar"
}
}
generateProtoTasks {
val krotoConfig = file("$projectDir/krotoPlusConfig.yaml")
all().forEach {
it.inputs.files.plus(krotoConfig)
it.builtins {
remove("java")
}
it.plugins {
id("javalite") {
outputSubDir = "java"
}
id("krotoPlus") {
println("kroto")
outputSubDir = "java"
option("ConfigPath=$projectDir/krotoPlusConfig.yaml")
}
}
}
}
}
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment