0

I have a Java multiproject which also contains some python build scripts:

my_project/
├── build.gradle.kts
├── settings.gradle.kts
├── module_a/
│   ├── build.gradle.kts
│   └── src/main/java/
├── module_b/
│   ├── build.gradle.kts
│   └── src/main/java/
└── buildscript/
    ├── build.py
    ├── common_func.py
    └── tests/
        ├── test_build.py
        └── test_common_func.py

IntelliJ recognizes the buildscript directory as Python if I manually mark it as a Source directory. I then get code completion and can navigate code. I can also run the tests normally.

But whenever I reimport the Gradle project, IDEA forgets about the buildscript directory, and I have to manually mark it as source again. What can I do to fix this? Some Gradle config, I assume?

Some additional info regarding the tests: I have sys.path.append(os.path.dirname(__file__) + '/..') at the top of the test files, and have an Exec task for them:

tasks.register<Exec>("testBuildScripts") {
    workingDir(rootDir)
    commandLine("python3", "-m", "unittest", "discover", "buildscript/tests/")
}
neu242
  • 15,796
  • 20
  • 79
  • 114
  • have you set build directory as a source in build.gradle?https://docs.gradle.org/current/dsl/org.gradle.api.tasks.SourceSet.html – Petr Rastegaev Apr 01 '20 at 08:25
  • @PetrRastegaev That document states that "A SourceSet represents a logical group of **Java source** and resource files". Will this work for Python source? Also, the build folder doesn't include the `java` plugin. – neu242 Apr 01 '20 at 08:40

0 Answers0