How can I clone a whole project in IntelliJ Idea? - intellij-idea

I want to run some tests in my project but I do not want to affect the
original code, and I wanto to clone the project so I can run tests there
Does anyone know how to clone a project on IntelliJ Idea 11?

Using your operating system File Explorer tool, just copy and paste the entire project directory somewhere new. All of the configuration should use relative paths by default.
If your IDEA project is .ipr based, then delete the new .iws file before opening the project.
If your IDEA project is .idea directory based, then delete the workspace.xml file before opening the project.

If you want to copy and rename the project too, like I wanted to clone a project in order to use it with a newer version of IntelliJ.
Copy the whole directory to a new location, for example on Linux:
cp -r myproject new/location/
To rename the project:
2.1. rename the project folder (e.g. mv myproject newproject)
2.2. get into the new project folder (e.g. cd newproject) and edit the .name file with a text editor.
Open the new project now in IntelliJ (you may want to remove the workspace.xml if you don't want to keep the open file history - I kept it) and enjoy your new project!

For copy with rename I had to do one more step to get it to stop referencing the old module name. That was to right click on the module in the project pane and do Refactor > Rename ( or do Shift + F6 ) to rename the module.
This was for IntelliJ IDEA 2016.3.3

I had a gradle project and the provided answers did not work. The project did not have a structure in IntelliJ and I did not see the source files.
The following worked:
Export project (Export to zip file)
Move the zip file somewhere new
Unzip
With IntelliJ, import as a new project with "open".
Better Solution of course:
Have it in a git directory, make a "test-branch" and try whatever you want to try.

Apparently the accepted answer doesn't work anymore with current versions of Idea and the many derived IDEs (I tried this with PHPStorm). The problem: most of the config files are located in the .idea subdirectory of your project, but the file .idea/workspace.xml also contains the ProjectId, and that should of course be unique. So, if you copied the project directory manually, the easiest fix is to change the ProjectId - from what I have seen you can enter any alphanumeric string, e.g. "ProjectId123".
As far as I can see the main settings that are stored under the ProjectId are the workspace settings, under ~/.config/JetBrains/[IDENameAndVersion]/workspace/[ProjectId].xml. This file mostly contains the open editor tabs (with paths relative to the project directory) and the tool windows, so if you copy the project directory, you will always have the same editor tabs open in both projects (containing the "same" files, but from the respective project). If you want to avoid opening all files and setting up the tool windows, you can copy the old [ProjectId].xml file to e.g. ProjectId123.xml (using the ProjectId that you entered earlier).

After Copying your existing Project to a new folder don't forget to mark your src directory as Source directory. You can do this under Project Structure | Modules.

To duplicate and rename a CLion cmake project I followed the info in the other answers with some tweaks.
What seems to be the stepless way to eliminate all references to the old project name in the new one (tested with CLion 2019.1.2):
Copy folder
rename the new folder
On the new project folder:
delete the project info folder (CLion will recreate it):
<new project name>/.idea
On a text editor, open:
<new project name>/CMakeLists.txt
change every reference to the old project name with the new name and save it.
This will assure CLion will not use Project and Target info in "CMakeLists.txt" file to recreate project files and data in ".idea" folder with the old name.
Note that other info in this file referencing the old project folder, or files stored there, such as INCLUDE, SOURCE directories, and files, should also be changed to point to the new folder.
delete old compile data. Delete folders like:
<new project name>/cmake-*
Open project in CLion
It should have the new name and no reference to the old name anywhere.
If using CSV, you may also wish to delete old CSV data
EDIT: If project requires CUDA, CUDACXX environment variable must be reassigned to full path of nvcc compiler:
File->settings->Build, Execution, Deployment->CMake->Environment
IF CLion CUDA Run Patcher is installed it maybe needed to restart CLion.

Related

how to show original file structure in intellij?

I imported seldon-core to intellij, which tried to separate the files to different projects automatically.
How to disable this? I need to view all the files in original/same structure with the git repo, like:
Thanks
UPDATE
It STILL DOES NOT work now even I did the following:
When importing project, we need choose Project format as .ipr (file based).
Then, we need select Project Files
Have you tried switching between the options under projects? There is an option with project files
Project Files shows the exact file structure as your git repo.

Can't see project folders in IntelliJ IDEA

Every once in a while, I open an old project and I can't see any of the folders in the intelliJ project viewer. I can see all the files at the root.. but no folders. Yes I can delete the .iml file and .idea folder and re-create the project, but come on.. there's gotta be an easier way to fix this.
Is there?
If you look in project settings (ctrl-shift-alt-s), you should see a module structure. If you instead see "Nothing to see", do the following:
In Project Structure -> Modules, press the + button,
press enter (since, for some weird reason, it won't let me click on "New Module")
In the window that pops up, click on the "..." next to Content root, find your root folder, and select it
Press ok
ignore any warning that says the name is already in use (or to that effect)
the simplest solution worked from me, just delete the .idea folder
keep in mind this will delete all of idea's current project configuration, it'll create the folder with default settings when reload the project again... but all other configuration will be lost if not properly backed-up
It might be because the project didn't have any modules defined. Try adding existing source code by hitting File > New > Module from Existing Sources and select the parent directory of the project for source code
Go to pom.xml file -> right click -> maven -> generate source and update folders. You will see your files and folder structures in left hand side.
All the project-specific settings for a project opened through Intellij IDE are stored in the .idea folder.
The .idea folder (hidden on OS X) in the solution root contains
IntelliJ’s project-specific settings files. These include per-project
details such as VCS mapping and run and debug configurations, as well
as per-user details, such as currently open files, navigation history
and currently selected configuration.
So, if you are not able to see the project file structure in your Intellij IDE, just delete the .idea folder,
rm -rf .idea
and reload the project, then after reload you'll be easily able to get your project structure displayed.
Thank you very much. I just remove the .idea folder and works in my case.
rm -rf .idea
For me, the java folder was not showing up. I went into File->Project Structure. In the second column, I selected on _main. In the third column, I selected the tab "sources". In what I call the fourth column, where the "+Add Content Root" is shown, I verified, the java source/folder was present. In my case, there was an extra source folder, which was the current location. I removed this, applied and the java folder immediately showed up.
Right click on the Project name -> Open Module Setting -> Check the application context path set it up at your project location.
Check your idea.log -- it may have some details explaining why or what is happening (Help | Reveal log in Explorer). Possibly one of the config files got corrupted.
You can always backup and delete .idea subfolder (project settings) and re-create project from scratch. When it's wroking again (after basic configuration) you may copy some of the files from that folder back to recover some of your settings (if there were many).
This happened to me on a new computer when I opened up a Java project in the newly installed Intellij.
The problem was that I had not installed any JDK on the machine.
I had to install a JDK and then go into the settings at ctrl-shift-alt-s and add a JDK by specifying the folder where I installed it. It's possible that IntelliJ would have found it if I closed it and reopened it.
In my case the solution was to create a new project, specifying the project type and creating it within the same directory path as the project that does not load the project files correctly.
PhpStorm automatically detects that the directory exists and gives you the option to create project from existing sources.
This can be found under:
File --> New project...
For gradle users: "Reload All Gradle Projects" option should help.

How to rename project in RubyMine

I'm running Rubymine 5.4.x on Windows 7 (but that shouldn't really matter for this question) and I have managed to delete projects and seemingly rename them before, but I am stuck this time.
In the past, this is what I've done:
rename all instances of your old project name in all the files in the .idea folder in your project directory.
rename all instances of your old project name in all the files in the RubyMine config folder and subfolders (on windows, for RM 5.x - %USERPROFILE%\.RubyMine50\config)
rename all instances of your old project name in all the files in the RubyMine system folder and subfolders (on windows, for RM 5.x - %USERPROFILE%\.RubyMine50\config)
rename all FILES that contain your old project name to the new project name, a few examples - rename:
your actual project directory which would probably have the same name as the project to the new project name
the .idea/<your_project_name>.iml file
In Summary:
By deleting or modifying these files/folders I have managed to delete or rename the projects that appear in my "project list" in that startup screen/Create Project/Open Project Modal for RubyMine, and in the ReOpen Projects menu.
However, this time around I can't get the name of this particular project rename... that is it appears with the correct path in these lists, but the incorrect name.
Furthermore, the incorrect name appears in my Project ToolWindow once the IDE is launch, although directly to the right of it in parenthesis is the correct path.
Any thoughts? tia
To rename a project edit .idea/.name file manually.
There is a feature request to add Rename Project action to a File menu, please vote.
Updated answer done on RubyMine 6.3.3 when I wanted to rename the project directory:
Close RubyMine
Rename project directory to desired name
Delete the .idea folder
Reopen renamed project directory in RubyMine
I found this to be easier than combining the steps listed on the question and the accepted answer
OK... I just figured it out... IN ADDITION to everything above... you need to rename the .name file (it's just one line with the name of your project) in the .idea directory in the root directory of your project
In addition to modifying the .idea/.name file, there is also a .idea/<project name>.iml file. Open this, do a find/replace with <project name> and <new project name>, then rename this file as well.
Quit RubyMine, and reopen it. This will update everything. In your source control you'll notice a lot of other files which automatically got updated as well.
The .name does no longer exist in my version of RubyMine (2019.3)
The File|Rename project.. will automatically pick up the folder name change (if you changed it outside of RubyMine when it was closed)
Additionally, I had to rename the <project name>.mlt file in the .idea folder and change the references to it in idea/modules.xml (search and replace old project name to new project name)
<module fileurl="file://$PROJECT_DIR$/.idea/<PROJECT NAME>.iml" filepath="$PROJECT_DIR$/.idea/<PROJECT NAME>.iml" />

IntelliJ IDEA: How to rename a project (in "Recent Projects" list)?

Is there an easy way in IDEA 12 to rename a project in the "Recent Projects" list?
Found the solution.
You can rename the Project under "File > Project Structure > Project > Project Name".
Simply edit the file that contains the name: .idea/.name.
If your project is file based, you cannot rename the project from within IDEA.
Convert your project to a directory based format, and then you will have the option to rename it under "File > Project Structure > Project > Project Name".
This was just done on 14 ultimate.
Change your project using refactor. (first change your project folder name).
Select Project Name.
Select Refactor->Rename
Input new Project.
Everything should be ok now.
To rename project in IDEA 13 CE
Close IDEA project
Find project files *.ipr, *.iml, *.iws
Rename all these files as you want to be named project e.g. New Project.ipr(iml,iws)
Open project file in IDEA
I've tried the answer of #Matthias, #Ernest and #fhucho, but did not work (with 12.1.6CE).
What made it work was:
change the name of the project folder
find and rename the .ipr file, as proposed by #Ernest
Note: I did not have any .iml nor .iws file
change the name in .idea/.name
replace all occurrences for the initial project name by the new one in all .xml files
find them using:
find . -name "*.xml" -exec grep -Hn $InitProjectName {} \;
Rename all old*.iml to new*.iml
Open this project in Sublime Text, use Ctrl+Shift+F to replace all "old" to "new"
Then reopen this project and build it!
I found the solution to change “Recent Projects” list!
browse 'setting.gradle' in your project
change rootProject.name='new_project_name'
However, this way only changes the project name.
Try the answer of #Matthias together!
I completed the renaming as below.
The attached image is structured in project folder.
Must make changes in the xml into a new project name.
close IDEA intellij (14.0.2)
change intellij project name (folder)
e.g) old_project_name -> new_project_name
change .idea in folder
We have only changed the
1) artifacts in folder -> xml
2) runConfigurations in folder -> xml
3) modules.xml
4) workspace.xml
5) [your_project_name].iml
(Depending on your project structure, your folder may not contain xml)
restart IDEA intellij
File -> Import Module...[your intellij project]
I hope this helps you :)
I have tried all above solutions but the solution that worked for me is, renaming the folder manually after closing the IDE. Once it is renamed, it is all good to show the new project name.

Which file IDEA uses to display the name of Android project?

Which file in Android project does IDEA use to display project name in Recent Projects list?
If I want to change display name of my 8th project to "My changed project", which file should I edit? Is this done manually editing a certain file or can be done in a faster way via Ctrl+F6?
I am asking this as renaming module will not change display name.
Depending on the project format, IDEA uses either the .ipr file (its name, specifically) or some file buried under the .idea directory apparently.
Anyway, to change the project (display) name:
Projects using the newer directory-based format
(If you're not sure which format your project is using, try this first.)
Don't edit any file; instead, open the Project Structure dialog (Ctrl-Alt-Shift-S or ⌘;), and under General Settings for Project, change Project name.
Projects using the older file-based format
Find the main project settings file with .ipr extension, in your case LibraryTest.ipr, and simply rename that. Also rename the accompanying .iws file.
(NB: Close the project before doing this. Also, if there's an .iml module file with the same name, leave that alone. If you want to change names of modules, do that through Project Structure settings.)
The project will first disappear from the Recent Projects list; you'll have to use "Open Project" and find the newly renamed .ipr file to open it.