Can I add extra soure folder?

77 views
Skip to first unread message

Makoto Yamazaki

unread,
Jun 20, 2013, 11:16:23 AM6/20/13
to adt...@googlegroups.com
Hi,

Is there any way to add extra source folder to each Build Variant in build.gradle?

I'd like to use Pluggable Annotation Processing API (JSR 269).

I wrote build.gradle to use PAP as follows, but I couldn't find the way to add 
"${project.buildDir}/source/apt_generated/${variant.dirName}" as
an extra source folder.

android.applicationVariants.each { variant ->
    def aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}")

    variant.javaCompile.doFirst {
        aptOutput.mkdirs()
        aptOutput.eachFileRecurse groovy.io.FileType.FILES, {
            it.delete()
        }
        variant.javaCompile.options.compilerArgs += [
                '-processorpath', "<path of factory jar>",
                '-s', aptOutput
        ]
    }
}

I found two ugly workarounds.

First, I used "${project.buildDir}/source/r/${variant.dirName}" instead of 
"${project.buildDir}/source/apt_generated/${variant.dirName}".

Second workaround, I took over 'sourceOutputDir' of Renderscript.
tasks["compile${variant.name}Renderscript"].sourceOutputDir = aptOutput
It worked, and it's too ugly...

These two workarounds completely work with Build Variant switching in Android Studio,
but I'd like to avoid these ugly way...

any suggestions?

Xavier Ducrohet

unread,
Jun 20, 2013, 1:11:15 PM6/20/13
to adt...@googlegroups.com
There's no easy way to do this now, it's all going to be ugly.


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!
Reply all
Reply to author
Forward
0 new messages