Kotlin and java in the same directories for gradle build?


#1

I believe I read this is now possible in M11, but I am having errors like this with gradle:

e: C:cygwin64homebrand_000LWJake2srclwjake2gameentity_state_t.kt: (30, 7): Unresolved reference: edict_t

But edict_t is defined in LWJake2srclwjake2gameedict_t.java:

 
public class edict_t {

  /** Constructor. */
  public edict_t(int i) {
  s.number = i;
  index = i;
  }

My gradle file is posted along with the rest of the repo here, if it helps (not too long, but not sure what might be relevant as yet):

https://github.com/bbarker/LWJake2/tree/initKotlin

That said, this build.gradle is probably a bit far from being fully functional, if I had to guess; the working Ant build.xml is also in the directory.


#2

Hi, I've take a look at your build.gradle file and I think that the problem is here

sourceSets {   main.java.srcDirs += 'src/lwjake2' }

Your Java-files have package 'lwjake2.*', so the source directory should be

main.java.srcDirs += 'src/lwjake2'
Could you check if it helps?

#3

Thanks for taking a look. Lately, not just with Kotlin (or gradle), I feel that 80% of my problems can be traced to build systems :(.

If I understood you correctly, changing ‘src/lwjake2/’ to ‘src/lwjake2’ (removing the trailing ‘/’) still gives the same error.


#4

I'm sorry for my mistake. Source root should be

main.java.srcDirs += 'src'

#5

Great, this does it ... now I begin to understand how Gradle handles package names, though I still need to check a few thigns.