Gradle project structure organized different in IDEA - intellij-idea

I pull a project from github, while the project use the gradle as the build tool, and it contain some sub-projects, then I tried to import the project to IDEA, this is the procedure:http://pbrd.co/1lMpmyj.
http://pasteboard.s3.amazonaws.com/images/10QfmWBp.png
As shown, the sub-project are imported as separated project, while I want to keep the fold structure, something like this:http://pbrd.co/1lMpyO6.
Is this possible?
update:
gdx/settings.gradle:
include ':gdx-core'
include ':gdx-android'
include ':gdx-web'
This is the only settings.gradle inside the project.

Related

IntelliJ IDEA: how to restrict project tree view to a couple of folders

I'm working with IntelliJ IDEA in a rather large tree of projects almost exclusively on about 5 folders nested deeply in the hierarchy. Ideally I just want to see those 5 folders most of the time - the other projects and the other folders in their projects are usually just visual clutter. How can I get a view as close as possible to this with IDEA?
I do want all projects accessible in my workspace, so I can't just throw away the others. And even that would not help too much, because those folders are deeply nested in their projects. The favorites view almost does what I want, since you can unfold the folders there - but if there are some new files they are often not visible there (not sure whether this is a bug or a feature). Do you have other ideas? Thank you very much!
It depends on what you are trying to do. You can create scopes by criteria.
Go to preferences (mac) -> appearance & behavior -> scopes
There you can create local and shared scopes. You can manually edit these or use a regex pattern. The current reference documentation is located here.
Here are some examples from the jetbrains website of using regex.
file[MyMod]:src/main/java/com/example/my_package//* - include in a project all the files from module "MyMod", located in the specified directory and all subdirectories.
src[MyMod]:com.example.my_package..* - recursively include all classes in a package in the source directories of the module.
lib:com.company..*||com.company..* - recursively include all classes in a package from both project and libraries.
test:com.company.* - include all test classes in a package, but not in subpackages.
[MyMod]:com.company.util.* - include all classes and test classes in the package of the specified module.
file:*.js||file:*.coffee - include all JavaScript and CoffeeScript files.
file:*js&&!file:*.min.* - include all JavaScript files except those that were generated through minification, which is indicated by the min extension.

IntelliJ multi-project

Moving to intellij i'm trying to understand properly the logic behind the its project structure. I come from eclipse. After reading for a while i understood the relation between workspace and project, then between project and modules. However something that is puzzling me is the logic of the default project configuration in Intellij. Indeed, when you create a project there is an initial module which to a certain extend is equivalent to the Project itself. To be more precise, the initial module folder is the Project folder. This is kind of confusing to me. Then when you add more module they are sub-module of that module.
My first question is what is the rationale of making this first module equivalent to the project folder ?
Following this, i would further ask, what the point of having modules as sub-module of others.
In eclipse i use to have simply different project (i.e. module) independent from each other and adding the dependency as necessary. So how does the Idea solution makes it better, if not what is the rational here ?
I saw that one can start an empty project and then add modules to it. However in that case, the modules added are added as subfolder of the Project and therefore there is no initial module equivalent to the Project folder ? So why this difference and what is the rationale behind it ?
What would be the better approach, the first or second ?
Would it be ok to have this first initial module with no src or test folder but just with the proper facet so as to spread it to the sub-module?
I would appreciate if someone could explain a bit the rational of all of it ?
I will move to SBT soon (i.e. maven structure which I suppose inspired all modern IDE project Structure) if one want to explain within that context fine, nevertheless i want to understand the rationale in intelliJ first.
Many thanks,
-M-
PS: What i'm looking for is some advise for some multi-module project structure in Intellij as i'm moving my eclipse workspaces to it.
I think that it's not uncommon for projects to be relatively small, so they don't need fancy modules with dependency management etc. In that case, I find the default project created by IntelliJ to fit perfectly my needs: no need to add submodules, everything is directly in the parent project, it reduces the structure to its bare minimum.
On the other hand, big projects with submodules will likely resemble the structure of a Maven multimodule project (perhaps SBT too, but I don't know this tool at all). You have a parent root which acts as a container for submodules. The parent project may also store configuration (a default SDK, a language level etc. that will be inherited by the submodules). The actual code will be contained in the submodules.
Regarding your questions, it all depends on the kind of project you are developing. For a small codebase, you could keep a simple project with no submodule. For bigger codebases, you can either create modules manually, or import an existing Maven/SBT/whatever project, which will automatically create modules reflecting the imported structure.

How to add to project additional files not intended to be compiled?

I would like to add into project some files that shouldn't be compiled. I mean mainly text files with for example notes, concepts, comments etc.
I realized that it is possible only at module level. But it is not very convenient. I'd rather prefer to keep them on project level. Is it possible in any way?
And if not:
I have another idea: to create special module, name it for example "other_stuff", do not create src directory and put files there. Is it ok? I'm afraid of potential compilation problems when one of modules is artificial, with no sources but still has sdk assigned (it is probably impossible to leave module without sdk assigned).
While generating artifacts you can add any file into your artifact. Also, in modules you can have folders not declared as source, and they will not be compiled.

Extract sub-project from big project in IDEA

I have a BIG project in IDEA (basically the trunk of my company source code), but I need to work only on one of the "modules" (not sure how to call those). Is there a way I could export/create from/in IDEA a smaller project with the part of trunk I'm interested in? It's pretty self-contained, there should be dependencies only on 1 or 2 other projects in trunk.
There is no automatic option to extract a part of a project. You should create a new project from the existing sources, it will contain only required modules with content roots set to the parts of the bigger project and dependencies configured between them.

Using maven to create two artifacts with overlapping classes

I have a maven pom that creates an artifact, let's call it everything.jar.
I would like to copy a subset of the classes in everything.jar into another jar, let's call it mini.jar.
What's the best way to structure my maven pom(s) to produce two jar files, one called mini.jar with just a few classes, and the other everything.jar with everything in mini plus some additional classes, without actually making copies of the source?
I'd do it the other way around.
Create a multi - module project:
root
/ | \
mini extra everything
mini contains the core stuff
extra has a dependency to mini and defines the additional classes
everything has a dependency to both and uses the maven-shade-plugin to create a
combined jar from the two other
projects (you can also do that from
inside the extra project, but I'd
call that less elegant)
Reference:
shade:shade mojo
Selecting Contents for Uber JAR