Add task to download protoc (protobuf compiler) to root-level build/ directory
parent
0d416f0018
commit
abf4cc5e54
44
build.gradle
44
build.gradle
|
@ -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}/"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue