Edit: no longer need help, the issue was that the ...
# community-support
c
Edit: no longer need help, the issue was that the classes were generated into the default namespace. Hi, I'm trying to understand how to properly use generated sources in my project. I'm using javacc and jjtree to generate a parser. The generated
.java
files are written to
build/generated/javacc
. I have the following in my build script:
Copy code
sourceSets {
  main {
    java {
      srcDirs += "${buildDir}/generated/jjtree"
      srcDirs += "${buildDir}/generated/javacc"
    }
  }
}
The directories get added to my main module (screenshots 1/2). I can run the
main
method from the generated
SkritParser
(screenshot 3). However, I can't reference the generated classes from my main code (screenshot 4). If I press
ctrl+space
3 times, intellij finds the class in its dropdown, but it won't compile via intellij or by running
gradlew build
. I'm using gradle 8.12 and intellij 2024.3.1.1 Code: https://github.com/LordMonoxide/opensiege/compare/main.skrit
v
Well, if you configure source paths like that explicitly, you do need help still, even if you don't realize. :-D That is bad practice. You should always write task outputs and inputs. In this case - assuming the tasks generating the files properly declare their outputs, you would configure the task itself as
srcDir
. That was all source consumers have those files as sources and also the necessary task dependency automatically implicitly so that the files are generated when necessary.