Best way to work on a multi-language project from Github

Answered

I'm trying to work on the brotli project that's in Github (git clone git@github.com:google/brotli.git). It's a project that provides multiple source languages (java, go, csharp etc.). The java part of the project has a parent project and a ‘dec’ Module.

No matter what I try… File, Open… then choosing the parent pom file, or New… Project from Existing Sources, or Project from Version Control there always seems to be something wrong with the project structure. So for e.g. if I do “…from Existing Sources” and click on the pom.xml that's in …/brotli/java/org/brotli it opens the project as a maven project, and dec appears as a Module, but all the java files show as “Java file outside of source root”. 

brotli [parent] appears at the top of the project structure and immediately beneath are ‘common’, ‘dec’ (the Module!), ‘enc’, ‘integration’ etc. So there's no src/main/java… I can mark the various folders as “sources root” but I can't help feeling that's wrong. As soon as it tries to compile the classes after doing that, it complains about the package names “Package name org.brotli.common does not correspond to the file path ‘’ ”…which kind of makes sense because when it brings in the project, it doesn't make an org/brotli/common folder but just a folder named ‘common’ (and one called dec and integration and…) under the project root of brotli. Even after fiddling around for some time, manually making folders to match the package names, I usually end up that it then can't find the dec Module (or package…)

Probably doing something fundamentally wrong here that can be solved with 2 knowledgeable clicks of the mouse… or I need to bring in just the java part of the source and manually move it around to match the folder structure it should have?

Thanks for any advice!

 

0
5 comments

Hello!

Thank you for reporting this!

The following approach has worked for me:

  1. Clone the Project via IDEA (New → Project from Version Control…).
    You can also use an existing copy of the repository: close the Project, remove .idea folder from Project's root and re-open the Project (the root brotli folder) via IDEA's Open… dialog.
  2. Once  IDEA has cloned the Project, you should see a pop-up suggesting to import the detected Maven Project - click “Load”.

After that IDEA appears to successfully parse the Project's structure for both org.brotli:parent and org.brotli:dec, both Projects have build successfully in my environment.

Let me know if this approach works for you as well!

0

In regards to the Content Roots specifically: the Project in question has a highly unorthodox structure, that directly clashes with Maven's Standard Directory Layout and, for Maven-based Projects, IDEA relies on Maven's layout configuration.

You should, however, be able to work around this by adjusting the <sourceDirectory> and <testSourceDirectory> values.

For instance to

<sourceDirectory>../dec</sourceDirectory>

for the dec's pom.xml.

0

Many thanks for the replies. I'll have another look today, but it's already encouraging to hear it's not just me, the project is not well structured…

0

Yeah, I can build the project use Maven…Lifecycle… clean, install but can't work on the project. The source won't compile and I can't run any new classes I create.

So I'm now experimenting with creating the project structure as it should be and then linking to the source as it's cloned…e.g.:

mkdir src/main/java

cd src/main/java

ln -s ../../../../brotli/java/org/ org

Intellij still seems to be getting confused, goes round and round in a loop asking me to set an output folder (probably need to add stg to the pom) and can't find the junit classes (I suspect the project might be using a mix of junit4 and junit5, just to add to the confusion!). I tried creating a new Project, as it should be laid out, but that seems to confuse Intellij further because it can't find the dec Module, and if I manually add it, I end up with 2 dec Modules.

I haven't given up yet, but getting pretty close…

Thanks again,
Juleke

0

Juleke,

When compiling and running the Project make sure you are using Maven Run Configurations and not Build Menu options, as those, by default, rely on IDEA's Native Build System.

Considering the highly unusual Project structure, it might be worth reaching out to the Project maintainers on how the Project is intended to be used.

Is it possible that its' Maven part of it was not intended to be a standalone Project? 

0

Please sign in to leave a comment.