aboutsummaryrefslogtreecommitdiff
path: root/buildSrc
diff options
context:
space:
mode:
authorBrett Chabot <brettchabot@google.com>2017-11-15 14:41:47 -0800
committerBrett Chabot <brettchabot@google.com>2017-11-15 14:41:47 -0800
commit7b37943b98e459f465dff2a7c3350b76ca5636f4 (patch)
treeaa29ad03dd6681d816ec5c35f0053fdd316179a1 /buildSrc
parenta4c80088b2598049e1b8ec5921b91f4826e97d91 (diff)
parent2cb2af52674c1eaed747b43fe36212e23ac26e75 (diff)
downloadrobolectric-shadows-7b37943b98e459f465dff2a7c3350b76ca5636f4.tar.gz
Merge branch 'master' into rawres
Diffstat (limited to 'buildSrc')
-rw-r--r--buildSrc/src/main/groovy/ShadowsPlugin.groovy27
1 files changed, 18 insertions, 9 deletions
diff --git a/buildSrc/src/main/groovy/ShadowsPlugin.groovy b/buildSrc/src/main/groovy/ShadowsPlugin.groovy
index d680972be..54d672a40 100644
--- a/buildSrc/src/main/groovy/ShadowsPlugin.groovy
+++ b/buildSrc/src/main/groovy/ShadowsPlugin.groovy
@@ -1,5 +1,6 @@
import org.gradle.api.Plugin
import org.gradle.api.Project
+import org.gradle.api.tasks.compile.JavaCompile
import java.util.jar.JarFile
@@ -8,6 +9,7 @@ class ShadowsPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.apply plugin: "net.ltgt.apt"
+ project.apply plugin: 'idea'
project.extensions.create("shadows", ShadowsPluginExtension)
@@ -20,15 +22,13 @@ class ShadowsPlugin implements Plugin<Project> {
options.compilerArgs.add("-Aorg.robolectric.annotation.processing.shadowPackage=${project.shadows.packageName}")
}
+ // this doesn't seem to have any effect in IDEA yet, unfortunately...
def aptGeneratedSrcDir = new File(project.buildDir, 'generated/source/apt/main')
+ project.idea.module.generatedSourceDirs << aptGeneratedSrcDir
- project.sourceSets {
- main {
- java {
- srcDirs += [aptGeneratedSrcDir]
- }
- }
- }
+ // include generated sources in javadoc and source jars
+ project.tasks['javadoc'].source(aptGeneratedSrcDir)
+ project.tasks['sourcesJar'].from(project.fileTree(aptGeneratedSrcDir))
// verify that we have the apt-generated files in our javadoc and sources jars
project.tasks['javadocJar'].doLast { task ->
@@ -42,13 +42,22 @@ class ShadowsPlugin implements Plugin<Project> {
}
project.rootProject.configAnnotationProcessing += project
- }
+
+ /* Prevents sporadic compilation error:
+ * 'Bad service configuration file, or exception thrown while constructing
+ * Processor object: javax.annotation.processing.Processor: Error reading
+ * configuration file'
+ *
+ * See https://discuss.gradle.org/t/gradle-not-compiles-with-solder-tooling-jar/7583/20
+ */
+ project.tasks.withType(JavaCompile) { options.fork = true }
+}
static class ShadowsPluginExtension {
String packageName
}
- private void checkForFile(jar, String name) {
+ private static void checkForFile(jar, String name) {
def files = new JarFile(jar).entries().collect { it.name }.toSet()
if (!files.contains(name)) {