How to change all the package easily? - intellij-idea

I copy util package from other project to my project.
But all the java files' package is still the previous package path, so it is wrong.
enter image description here
See the upper snapshot, all the file under the util folder I copied from other project is still the com.jackov.common.util, how can I easily change the package to correct package instead of modify one by one.

Copy them to the original package they were in the old project (create it in the new project), then use Refactor | Move to move them to another package (or Rename the package). IDE will update all the imports automatically.

Here's a quick and dirty solution:
Edit > Find > Replace In Files
Find: package old.package.name
Replace: package new.package.name
Select In Project
Press Enter.

Related

Copying a project for Sidekick

When I copy a project, I give the project folder a new name particularly if I want maintain the old version and create a new version with additional features. The problem with this is the compiled project takes the name from the folder name of the project which is a pain. For example if the initial is folder is myproject and I create a new folder myprojectwithfeatures, the file once installed becomes myprojectwithfeatures and not myproject. In sidekick, the project name/App name cannot be changed it is greyed out.
Is it possible to change the App Name to maintain the name across versions.
When I copy a project, I use the tns create command thusly:
tns create mynewapp --appid domain.mynewapp --template <path to>/myoldapp/app
This seems to work well.
I personally don't use SideKick but you can always update the project name to anything by modifying CFBundleDisplayName entry in App_Resources/iOS/info.plist and android:label="YourAppName" attribute of application tag in App_Resources/Android/src/main/AndroidManifest.xml
More details can be found here.

Dart packages problems with intellij IDEA

I'm actually trying to use Dart in IntelliJ IDEA, and I have successfully install the plugin for it, but I face numerous others problems.
But the problem I want to resolve the most, is the fact that for some packages, IntelliJ doesn't show the sources inside it and not with particular reason...
The whole project work in Dart Editor, and launch correctly, so the problem is not from pubspec.yaml.
To makes me more understandable, I will say that I "pub get" correctly the packages A and B, so they appear as folder link in IntelliJ :
http://imgur.com/rb0ZSVA
But like you see, I cannot enter in the b package to see the files inside it. I have checked the structure of the two folders without noticing any difference.
The more ridiculous in that is, I can see some of the files inside the B package in the editor of IntelliJ via Ctrl+Click in the dart files that import the files inside the B package. And it doesn't work for all of them ...
'b' is a 'path package' in your project. That means that b original source code is located on your computer and you specified path to it in pubspec.yaml. IntelliJ IDEA excludes all copies and leaves only original files in project. Root 'packages' folder is not excluded, but all its copies (for example in web folder) are excluded. packages/b is a copy and it is excluded. To work normally with source files from b package you should add path to b as a separate content root: Project Structure | Modules | your Dart module | Add content root.
In IntelliJ IDEA 14 excluded folders are visible by default. Use cases when you need to see excluded folder contents are rare so you may safely hide them (the option is under the gear in the Project View tool window title). With it you will see empty node in packages/b with a hint that it is just a link to b/lib folder. And anyway you should have path to b configured as a content root.
You should not open files of projects currently open in IntelliJ from the package folder but instead directly from the project. The b/lib after the folder icon indicates that this package is part of your currently opened IntelliJ project (may added as a Resource Root)
When you navigate to a referenced file ctrl+click the file is not opened from the packages symlink but from the package in your IntelliJ project (as you should do it manually as well).
The solution is to update IntelliJ to the Early Access update (139.2).
So this question will be useless in the next update, I will delete her at that moment.

How can I clone a whole project in 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.

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.

Rename empty package?

How can I rename empty package name in IDEA 11? I can rename only a package which has files in it.
For example, I have a package com.example.test with subfolder parser.xml. How can I rename parser folder? Pressing Ctrl+F6 will only let me rename xml folder.
PS. What would happen if I open a system's file manager and rename a folder there? Will IDEA properly handle such renaming?
Click on the gear icon in the Project view and disable the Compact Empty Middle Packages option. This way the project folders will be represented in a tree where each subfolder is a separate node, so that you can rename them individually.
PS. What would happen if I open a system's file manager and rename a folder there? Will IDEA properly handle such renaming?
No, IDEA will not handle such rename as a refactoring and will not update any references.