Hi,
I work on a plugin that compiles .proto files to .java and would like to integrate with the kotlin plugin. I want the outputted java files to be included by the KotlinCompile task as inputs. It seems that for non android kotlin projects, I can pass a File or SourceDirectorySet to the task’s source like so, and it works. But the analogous thing does not work on android.
project.sourceSets.each { SourceSet sourceSet ->
project.protobuf.generateProtoTasks.ofSourceSet(sourceSet.name).each { GenerateProtoTask genProto ->
['java', 'kotlin'].each { String lang ->
Task compileTask = project.tasks.findByName(sourceSet.getCompileTaskName(lang))
if (compileTask != null) {
compileTask.dependsOn(genProto)
genProto.getAllOutputDirs().each { dir ->
SourceDirectorySet generatedDirSet = new DefaultSourceDirectorySet(dir.toString(), fileResolver, new DefaultDirectoryFileTreeFactory())
generatedDirSet.srcDirs(dir)
generatedDirSet.include("**/*.java")
compileTask.source generatedDirSet
}
}
}
}
The beginning of linkGenerateProtoTasksToJavaCompile is the code for handling android projects:
When I build testProjectAndroid by running ProtobufAndroidPluginTest, I get an error that KotlinBar.kt failed to resolve the HelloWorld class. If I set a breakpoint on line 445, I see that the KotlinCompile task does have HelloWorld.java in its sources by adding a breakpoint to the kotlin tasks’s doBefore{}.