Intellij: how to expand to two folders?

General question: how to work with many different git repos at the same time in one intellij project. Where git repos should be inside the main application (i.e. one git repository). I cannot use symbolic links because I cannot follow these

I have 2 git repos

one for the main application, the other for a library that I am using in multiple projects.

This is how it goes: I have a main application. Through composer, I add my library / package to the application.

Problem:

Folder structure

:

to develop

IdeaProjects/myappA

Note: there are also IdeaProjects myappB

etc.

IdeaProjects/mylib

myappA has

IdeaProjects/myappA/vendor/mylib

deployment server folder:

/var/www/www.myappA.com/

I make a lot of changes to the library, I open it as another module when I work on myappA

, so I make code changes to mylib

in this folder / module which actually contains the source code mylib

. Now I don't want composer to install or update every time I make a small change. So what I do is I deploy via intellij the files from the library mylib

every time I save directly to the composer install folder of my main app for example. before IdeaProjects/myappA/vendor/mylib

. Now the problem is I need to deploy it to the server deployment folder too. But it is not possible to expand files into two folders out of the box using intellij.

What else can I do?

I am currently manually using the shortkey to run an ant build which then copies the folder IdeaProjects/myappA/vendor/mylib

to the server deployment directory.

+3


source to share


2 answers


There are several solutions depending on your installation:

solution inside intellij: just import mylib as a module inside your myapp project Go to File > Project Settings > Modules

, click +

and selectimport module

import module

git own solution: use submodules



Submodules allow you to store a Git repository as a subdirectory of another Git repository. This allows you to clone another repository into your project and keep your commits separate.

Please note that there are some quirks when working with submodules, especially the way to keep the submodules up to date

For completeness: if you were using gradle or maven instead of ant, you could use their respective project views and use +

to add multiple build.gradle or pom.xml files that will automatically import those projects as modules into intellij.

+4


source


I think the module approach suits your case, and yes, you can have a different git repo for each module. Right click on the root of the project, new->module

orfile->new module from existing source

Intellij should also automatically detect every git repository in your project, if you check Settings | Version Control

you should see a list.



You can also speed up some operations like git pull

, instead of fetching from each repository ( VCS -> Git -> Pull

), you can do VCS -> Update Project

or ctrl-t

( cmd-t

on mac)

0


source







All Articles