How to add a folder to an android project sourceset from a gradle plugin -
i'm writing plugin gradle, generate classes android projects.
i generate classes in projects src/gen/java
folder, don't want them mixed real source code.
from project's build.gradle
config, can add make build tools see generated classes :
android { sourcesets { main { java { srcdir 'src/gen/java' } } } }
the problem want plugin set automatically. plugin tried followings :
public class myplugin implements plugin {
@override public void apply(project project) { // ... // test 1 : doesnt work project.android.sourcesets.main.java.srcdirs += "src/gen/java" // test 2 : doesnt work project.android.sourcesets { main { java { srcdir 'src/gen/java' } } } }
}
each time plugin works, folder still not seen compiler , can't find generated classes when compiling. 1 know of way plugin ?
if move files to build/generated/sources
dir of app module plugin generating code don't have add source set.
you @ sqldelight gradle plugin code generation or autovalue
edit:
you need call registerjavageneratingtask on buildvariant generate sources
Comments
Post a Comment