If anyone else is having trouble importing ofbiz-framework into IntelliJ due to duplicate content roots, JetBrains have a survey on the topic here: https://survey.alchemer.com/s3/7917344/Shared-file-support-in-IntelliJ-IDEA
On Thu, 17 Oct 2024 at 16:18, Daniel Watford <d...@foomoo.co.uk> wrote: > Some progress and a partial explanation of what is happening. > > From various internet searches regarding Gradle and IntelliJ, it seems > that IntelliJ will not import modules from a Gradle build definition where > the same content path is used in multiple modules. > > A gradle sourceSet is mapped to an IntelliJ module. A sourceSet will have > one or more srcDirs to location source files in a project. > > In our gradle build, defined in build.gradle at the project root, we > utilise two sourceSets, main and test, to which we add numerous srcDirs > from the project's components. > > In settings.gradle we also add each of the components as a gradle > sub-project. Each of the sub-projects will have the main and test > sourceSets added by the java plugin, with default directories of > src/main/java, src/test/java, etc. > > The duplication appears to come from having both the root project and the > sub-project referring to directories, such as src/main/java. IntelliJ > detects that the two modules are referencing the same path and removes one > of them. > > It seems that we don't need each component to be added as a gradle > sub-project in our builds since (in the majority of cases) all sources have > been added to the root project's sourceSets. To test this idea I commented > out the following from settings.gradle: > > activeComponents().each { File component -> > def subProject = (component.toString() - rootDir) > if (isWindows) > include subProject.replaceAll('\\' + fileSep, ':') > else > include subProject.replaceAll(fileSep, ':') > } > > The above code added a gradle sub-project for each component to the root > project. By commenting this code out, the sub-projects were removed and > IntelliJ imported the ofbiz-framework project without error. > > I still cannot explain why the duplicate paths issue was only found in the > devcontainer and not when running IntelliJ on the host. > > We also cannot simply remove all gradle sub-projects since we do allow use > of gradle tasks in plugins, and we use sub-projects to apply the gradle > node plugin in a few places. > > I don't have a solution yet, but just wanted to highlight that some > strange import behaviour in IntelliJ might be related to our potentially > superfluous use of gradle subprojects. > > Any ideal on how we should handle gradle sub-projects? Perhaps we only add > sub-project for components that have a build.gradle file? > > > On Thu, 17 Oct 2024 at 15:00, Daniel Watford <d...@foomoo.co.uk> wrote: > >> Hello, >> >> I've noticed that if I run IntelliJ in a dev container for the >> ofbiz-framework trunk branch, not all source directories are recognised by >> the IDE following the Gradle Import process. >> >> After running the IntelliJ Gradle import I see a message similar to the >> following: >> >> Path [/IdeaProjects/ofbiz-framework/applications/accounting] of module >> [ofbiz.applications.accounting] was removed from modules [ofbiz.main]" Also >> 18 more paths were deduplicated. See idea log for details >> >> I do not see this message when running IntelliJ directly on the host. >> >> After working on this for several hours, I'm still unable to explain this >> discrepancy between the two approaches to running IntelliJ. >> >> Has anyone else noticed this behaviour with IntelliJ and if so, are they >> using devcontainers, Windows, Linux, what versions of JDK, etc? >> >> Thanks, >> >> Dan. >> >> -- >> Daniel Watford >> > > > -- > Daniel Watford > -- Daniel Watford