This is a Gradle plugin that acts as a wrapper of the ScalaBuff tool.
It automatically applies the scala
plugin and adds the tasks scalabuffCompile
and generateProtoDescriptors
to Gradle. Normally there is no need to call or configure these tasks, they are nicely integrated in Gradle build lifecycle.
Scala library version is inferred after project evaluation, so the user must declare it as a compile
dependency.
A simple example script:
// Using the new, incubating, plugin mechanism introduced in Gradle 2.1
plugins {
id 'com.github.rafael-brandao.scalabuff' version '0.2.0'
}
apply plugin: 'com.github.rafael-brandao.scalabuff'
scalabuff {
// Plugin configuration goes here, but it is optional
}
repositories {
jcenter()
}
dependencies {
compile 'org.scala-lang:scala-library:2.11.4'
}
or the traditional way:
// Build script snippet for use in all Gradle versions
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.rafael-brandao.gradle:scalabuff-gradle-plugin:0.2.0'
}
}
apply plugin: 'com.github.rafael-brandao.scalabuff'
scalabuff {
// Plugin configuration goes here, but it is optional
}
repositories {
jcenter()
}
dependencies {
compile 'org.scala-lang:scala-library:2.11.4'
}
Full plugin configuration example (showing the default settings):
plugins {
id 'com.github.rafael-brandao.scalabuff' version '0.2.0'
}
apply plugin: 'com.github.rafael-brandao.scalabuff'
repositories {
jcenter()
}
dependencies {
compile 'org.scala-lang:scala-library:2.11.4'
}
scalabuff {
sourceSets {
proto {
srcDir = 'src/proto'
}
}
outputDir = file("${project.buildDir}/scalabuff") // read-only
generatedSourcesDir = file("${scalabuff.outputDir}/generated-sources") // read-only
generatedResourcesDir = file("${scalabuff.outputDir}/generated-resources") // read-only
failIfProtocNotDetected = false
generateDescriptor = true
protocPath = 'protoc'
}
${scalabuff.sourceSets}
directories for any .proto
files;.proto
file found to a valid Scala class using the ScalaBuff tool;${scalabuff.generated-sources}
directory;${scalabuff.generated-resources}
. For example, a file named myFile.proto
will have it's descriptor file named as myFile.proto.descriptor
.scala
plugin;scalabuff-runtime
library;${scalabuff.generated-sources}
directory to ${sourceSets.scala.main.srcDirs}
for compilation;failIfProtocNotDetected
is set to true, the plugin fails the build if it can't detect protoc
command in the path;protocPath
to provide a configurable way to find protoc
command. It defaults to 'protoc'
scalabuff
version is 1.3.8
Released under the Mozilla Public License, Version 2.0