Add task to download protoc (protobuf compiler) to root-level build/ directory

mixer
Tal Moran 2017-01-18 21:54:22 +02:00
parent 0d416f0018
commit abf4cc5e54
1 changed files with 44 additions and 0 deletions

View File

@ -1,3 +1,6 @@
plugins {
id "com.google.osdetector" version "1.4.0"
}
subprojects { proj ->
proj.afterEvaluate {
@ -8,3 +11,44 @@ subprojects { proj ->
}
}
}
// Script to create a copy of the protobuf compiler jar in the top-level build directory
// (will make it easier to configure the intellij protobuf plugin)
repositories {
mavenLocal();
mavenCentral();
}
project.ext.protocLocation = 'com.google.protobuf:protoc:3.+'
// Copied from Google's protobuf plugin code
File getProtocDep(protocLocation) {
// create a project configuration dependency for the artifact
Configuration config = project.configurations.create("protobufToolsLocator") {
visible = false
transitive = false
extendsFrom = []
}
def groupId, artifact, version
(groupId, artifact, version) = protocLocation.split(":")
def notation = [group: groupId,
name: artifact,
version: version,
classifier: project.osdetector.classifier,
ext: 'exe']
Dependency dep = project.dependencies.add(config.name, notation)
File file = config.fileCollection(dep).singleFile
return file
}
task getprotoc(type: Copy) {
from getProtocDep(project.ext.protocLocation)
rename { file -> return "protoc" }
into "${buildDir}/"
}