How to compile generated and non-generated classes in gradle when non-generated classes(.java) are dependent on generated classes(.java)?
My generated classes are in $buildDir/generated-sources/thrift My non generated classes are in src/main/java
The generated classes (.java files) are need to compile the non generated classes (.java files again) to finally put everything under $buildDir/classes/main (all .class files should be here)
Another way to say this would be my non generated classes in (src/main/java) need generated classes as a library dependency (.class files) to compile and run. So far I have the below build.gradle but it doesn’t quite work
The Thrift Plugin doesnt do lot of stuff but I am kind of stuck with it. here is the plugin that I use https://github.com/jruyi/thrift-gradle-plugin. I am just trying hard to see if there is a way to fix my problem. The main problem here is that everything works fine as long as I put my .thrift files under src/main/thrift (The line that has been commented above because I have a requirement that my .thrift files should be outside of my project). so when I give it the right path sourceDir “$buildDir/…/…/…/lib/service_api” it doesn’t work. It only works when I set it to sourceDir src/main/thrift. All this because my non generated source code has a compile time library dependency of generated code which means the generated code should be compiled ahead and put its .class files under build/classes/main before I compile my non generated source code. Again everything works fine as long as I set it to sourceDir src/main/thrift but the moment I set it to sourceDir “$buildDir/…/…/…/lib/service_api” as per my requirement it doesn’t work.
It just throws me bunch of errors saying that “java cannot find symbol class some-non-generated-class location some-genereated-class.java” I tried it again with sourceDir src/main/thrift and it works fine but didn’t work with sourceDir “$buildDir/…/…/…/lib/service_api” (I made sure This location is correct also).
That would take a good amount of time because thrift is a tricky one to handle. is this a hard problem to solve? can stack trace help that I get from gradle build --debug?
I created a symlink as follows ln -s src/main/thrift/filename.thrift and it worked however It doesn’t make a lot of sense although it fixes my problem for now