-
-
Save RdeWilde/7d0e9d491feff6df5c05b4e795f0ba16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.protobuf.gradle.* | |
import com.google.protobuf.* | |
plugins { | |
idea | |
application | |
// kotlin("jvm") version "1.3.11" | |
id("kotlin-multiplatform") version "1.3.11" | |
id("com.google.protobuf") version "0.8.7" | |
} | |
project.extensions.add("protobuf", ProtobufConfigurator(project, null)) | |
buildscript { | |
repositories { | |
google() | |
mavenCentral() | |
jcenter() | |
} | |
dependencies { | |
classpath("com.google.protobuf:protobuf-gradle-plugin:0.8.7") | |
} | |
} | |
configurations.all { | |
resolutionStrategy { | |
failOnVersionConflict() | |
eachDependency { | |
when (requested.group) { | |
"com.google.protobuf" -> useVersion("3.6.1") | |
"io.grpc" -> useVersion("1.17.0") | |
} | |
} | |
} | |
} | |
apply { | |
plugin<JavaPlugin>() | |
plugin<ProtobufPlugin>() | |
} | |
//configure<ProtobufConfigurator> { | |
// generatedFilesBaseDir = "$projectDir/src" | |
//} | |
repositories { | |
google() | |
mavenCentral() | |
jcenter() | |
maven(url = "https://jitpack.io") | |
} | |
group = "com.example" | |
version = "0.0.1" | |
kotlin { | |
targets.apply { | |
targets.add(presets["jvm"].createTarget("jvm")) | |
} | |
sourceSets.apply { | |
getByName("commonMain") { | |
dependencies { | |
implementation("com.google.protobuf:protobuf-gradle-plugin:0.8.7") | |
implementation("com.google.protobuf:protobuf-java:+") | |
implementation("io.grpc:grpc-stub:1.15.1") | |
implementation("io.grpc:grpc-protobuf:+") | |
implementation("org.jetbrains.kotlin:kotlin-stdlib-common") | |
if (JavaVersion.current().isJava9Compatible) { | |
implementation("javax.annotation:javax.annotation-api:+") | |
} | |
} | |
} | |
getByName("commonTest") { | |
dependencies { | |
implementation("org.jetbrains.kotlin:kotlin-test-common") | |
implementation("org.jetbrains.kotlin:kotlin-test-annotations-common") | |
} | |
} | |
} | |
} | |
configure<ProtobufConfigurator> { | |
protobuf { | |
protoc { | |
artifact = "com.google.protobuf:protoc" | |
} | |
} | |
} | |
// plugins { | |
// id("grpc") { | |
// artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion" | |
// } | |
// "grpc-kotlin" { | |
// artifact = "io.rouz:grpc-kotlin-gen:0.1.0:jdk8@jar" | |
// } | |
// } | |
// generateProtoTasks { | |
// ofSourceSet("commonMain").forEach { | |
// it.plugins { | |
// id("grpc") {} | |
// } | |
// } | |
// } | |
//} | |
configure<JavaPluginConvention> { | |
sourceSets { | |
this["main"].java.srcDir(the<ProtobufConvention>().protobuf.generatedFilesBaseDir + "/main/java") | |
} | |
} | |
tasks["build"].dependsOn(tasks.withType(GenerateProtoTask::class.java)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment