I just start learning the Intellij. I create a small project and create several java files in a module. There is one thing bothers me, that Intellij always do a "make", which takes about 6-8 seconds, every time before run or debug the java code, no matter if I changed the code or not. I have turned on the "make project automatically" setting in compiler setting. Anyone have a idea?
Take a look at http://devnet.jetbrains.com/docs/DOC-192
One of the things mentioned at the very top is about antivirus tools:
Example : Configuring McAfee OAS
Most antiviruses allow specifying folders which are excluded from on-access scan.
For example, on my system with McAfee Enterprise, I found out a folder (c:\Dev) that was excluded by the OAS (On Access Scanner):
Moving both the installation folder, as well as the Intellij system folder (c:\Users\$user\.IntelliJIdea12) into that folder resulted in a appreciable improvement in IntelliJ performance.
Symlinking instead of moving!
If you already have IntelliJ installed then the least disruptive way of doing it is creating Symlinks. For example, for the IntelliJ system folder you would do the following:
Move c:\Users\$user\.IntelliJIdea12 to c:\dev\.IntelliJIdea12
Symlink : mklink /J c:\Users\$user\.IntelliJIdea12 c:\dev\.IntelliJIdea12
Do the same for the IntelliJ installation folder.
In my specific case, I was having an issues with large Maven Projects in IntelliJ. This is what worked for me : Tips for Handling large projects with Maven and IntelliJ IDEA
To be considered as "temp" answer, because the solution is not optimal. I really don't want to disable such whole "System Watcher" function of Kaspersky.
After consulting other threads, it seems that it's because of my Kaspersky System Watcher is slowing down the process. After turnning off the "System Watcher", the "make" finish in half a second. I wonder what "suspicious" activity in Intellij stimulate the "System Watcher".
Related
I am an Eclipse/STS user/developer, now trying to use IntelliJ Idea (CE)
2020.2.(1,2,3)
For a project based on Gradle, how spring-integration, when I open the IDE it happens the following
Ok, let the IDE load the project ... but
From above, that is the problem, I don't want that the IDE starts automatically to build/rebuild the project. I just need, open the project and that's all.
Observation: for example in Eclipse/STS exists the option to disable Build Automatically
I did do a research in the Web and I read the following posts and questions:
How to disable automatic gradle builds?
IntelliJ IDEA “Build project automatically” apparently not working
Intellij IDEA Java classes not auto compiling on save
Sadly the dialog options were changed but ...
Therefore:
From above, seems nothing to do.
Observation: from above observe the Build project automatically option is disabled
Even with that disabled and after to restart the IDE, I must always stop manually the build process
So what is missing? or Do I need a special extra plugin to accomplish my goal?
The images that you show indicate that you are building with Gradle, but the Compiler option that you disable is relevant for building projects with Idea not with Gradle.
For the 2020.2 version, you need to do the following:
Open the Setting > Build Tools page.
Disable the "Reload changes in build scripts" option.
This way you can manually control the reload. When you change the build script, you will see a small gradle icon in the right side of the editor.
For more info, refer to the IntelliJ IDEA help > Gradle section.
https://www.jetbrains.com/help/idea/work-with-gradle-projects.html#auto_reload
There are two different things in IntelliJ's Gradle support that sometimes confused: sync and build. Your pictures demonstrate sync process (note caption on the toolwindow). Word build is kind of misleading here.
What is sync? In gradle we use Groovy to define the build procedure. Groovy is an imperative programming language, so it's hard to predict resulting dependencies graph without actually executing the script. During the sync Idea executes configuration phase of gradle build (one that builds dependency graph), and obtains configured objects from the Gradle daemon. This information is used to setup project in the IDE: modules, libraries, dependencies, which sources are test, which are prod, etc.
Actual build is not happening during sync. You can convince yourself by adding syntax error to any source file, and observe that the sync succeeds. But build will fail if you invoke it.
In answer to the original question: you can't disable automatic build, because it is not enabled.
Is it possible to disable sync in Gradle project? Short answer - no. If you need a code browser, which is not required to understand all the cross-references in the source code, IDEA is not the best choice probably.
TL;DR;
Without sync IDE does not know which files are sources, and which are not. IDEA cannot open folders. It only can open projects. Good thing is that module can contain folder. So you can do the following: File | New | Project. Select Empty project, Next, select some random folder outside the source folder you want to open, Finish.
Then add new module:
Select Java in the left panel, everything else keep default, Next, Finish. Then in new module remove existing content root, and add folder with sources as new content root
Resulting project is mostly useless. Tons of red code (at least, unresolved symbols from external libraries), no inspections, no navigation, no sense. But it might be useful in some rare situations indeed.
I have a project in IntelliJ IDEA, inside that a couple of modules and one of my modules has two build configurations. One of them needs to copy a <projectroot>/tools folder to its out/production/<BuildConfigurationName> folder. Can IDEA somehow automate this?
The accepted answer above is incorrect. IDEA can do this (without ant/gradle) via the artifacts system (accessed via Build menu or project settings). Any one artifact job copies multiple files/folders/build outputs to a chosen location (optionally jarred) and can be set to automatically run on make.
Artifacts can even be chained, i.e. output from one as input to another.
Can IDEA somehow automate this?
Not directly, no. Ultimately IDEA is an IDE and not a build tool. While it can do a lot during a build, it does not have the ability to copy non-source files to an alternate directory, let alone a dynamically named directory.
If you marked the tools directory as a source directory (and none of its contained file types were set in the "Ignore files and folder" setting at the bottom of the "File Types" settings dialog), IDEA would then copy the tools directory to the out directory. But renaming requires a more sophisticated build tool.
Ultimately, the "ideal" or "best practices" solution would be to build your project using a build tool like Maven, Gradle or Ant for which this type of thing would be a snap.
If that is not an option, or for some reason you really want IDEA to do the build, the best thing you could do is to write a simple Ant script to the copy for you. (Or possibly Gradle, I do not have much experience with Gradle yet. Maven could do it, but it'd be a bit cumbersome compared to Ant.) In any Run/Debug configurations, you can define the ant script target to run before or after the IDEA "make" in the Before Launch section. (You can set that as a default for any newly created configurations by configuring it in Defaults on the left). If you run your build manually, you can assign a shortcut to the ant build and then run it and the make in sequence. Alternatively, you could record a Macro (Edit > Macros) to run both in sequence and then (optionally) assign the macro a keyboard shortcut.
I made changes to Intellij Community Edition (ce). I can compile and run those changes from within the IntelliJ editor. That launches a second instance of IntelliJ ce which is running from classes containing my changes. What I want to do is just run those changes without having to first load the source, compile and run from within IntelliJ.
Netbeans made this easy by just producing an executable as a result of the build. With Intellij, it's not at all clear what has to be done. I have tried the following-
using the Run configuration Intellij itself uses to run the altered classes- this includes setting the working directory , main class, vm options and classpath. Actually, this doesn't work for reasons unknown to me.
on someone's suggestion, running dist.gant in build. This blows up with very many errors which are not helpful (no class def found errors which indicate some confusion on Intellij's part on classpaths somewhere)
Running WinLauncher.exe under bin gives the error message that it can't find VM options file (although it's in bin, (and also for good measure under bin/win with the other files which are co-located with vmoptions in the intellij directory structure for Intellij proper. )
ALl this is just harder than it should be. The solution is to provide an executable as a result of the build and place it in a predictable location.
Has anyone ever actually DONE what I am trying to do- make changes to the community source then use the resultant editor not as a project you're working with in IntelliJ but as the Intellij editor you're working through?
FOLLOW UP
User60561 had the correct answer. Just to mop up the details, in artifacts, there is a compressed file (win.zip for Windows, mac.zip for Mac etc.). In order to run your snapshot, you have to unzip this archive (after which it will have the same name, minus the zip extension) then go into folder "bin". There you'll see two executables: idea.exe and idea64.exe, for 32 and 64 bit versions, respectively. Clicking on these runs your snapshot.
Adjusting contents of the files idea.exe.vmoptions and idea64.exe.vmoptions lets you set the VM parameters to suit yourself, typically people might want to give the VM more memory through the -Xmx value.
It seems straightforward:
To build the distribution archive of IntelliJ IDEA Community Edition, execute build.xml Ant build script in the root directory of the source code. The results of the build execution can be found at out/artifacts.
https://github.com/JetBrains/intellij-community#building
So download ant, and run ant in the directory that you have it stored in. Make sure to use the commandline to launch ant in order to make sure everything is working correctly.
Initially execute getPlugins.bat/sh, then:
Use update.bat/sh according to it's instructions
Or
Click on: Main Menu | Build | IntelliJ IDEA CE build
Copy content of intellij-community\out\deploy (lib, plugins folder) into existing IJ installation (sometimes it is better to delete existing folders if they contain older dependencies or when the installation was of Ultimate version)
I find myself often running the same goals (clean install) of different, interdependent maven projects in Intellij IDEA one after another.
Does anyone know of a way to configure something like a maven goal combination, ideally such that you configure a button in IDEA's task bar that you can hit to execute these goals in sequence? Possibly even with a keyboard short cut?
Similar things might be achieved with a maven run configuration, but then IDEA wouldn't automatically be aware of the changes the run does to the project's file system resources.
Cheers,
Johannes
Easy solution for me was to create a Run Configuration (type=Maven) per module, putting multiple goals (e.g: clean install) as cmd line for each of them, then linking them up into a chain, by adding an appropriate one under the "Before launch" section.
You can link up the last of the chain as a "Before launch" for the actual app Run.
Then you can, if required, just restart a running instance if your app which will rebuild your maven projects in order, and start the app again.
I frequently run a clean install of my maven aggregator project from the command line while it is open in IntelliJ. In my experience the IDE seems to handle this quite well.
when you open the MVN - 'Run Anything' appears - beside that there is a PROJECT drop down, from which you can select for which project you want to run the maven command.
Nine times out of ten when I run mvn clean on my projects I experience a build error. I have to execute mvn clean multiple times until the build error goes away. Does anyone else experience this? Is there any way to fix this within Maven? If not, how do you get around it? I wrote a bat file that deletes the target folders and that works well, but it's not practical when you are working on multiple projects. I am using Maven 2.2.1.
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to delete directory: C:\Documents and Settings\user\My Documents\software-developm
ent\a\b\c\application-domain\target. Reason: Unable to delete directory C:\Documen
ts and Settings\user\My Documents\software-development\a\b\c\application-domai
n\target\classes\com\a\b
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Fri Oct 23 15:22:48 EDT 2009
[INFO] Final Memory: 11M/254M
[INFO] ------------------------------------------------------------------------
It may be that your IDE or some other process is holding on to the the "target" folder and preventing maven from deleting it.
This is mostly caused by Windows Indexing. Excluding target folders or .jar extention from indexing will fix the problem. My best practice is excluding .jar extention.
To exclude target files:
Click on windows icon/start menu
Type indexing in search box and click on Indexing Options
Then click on Modify button to investigate directories indexing.
Remove checks of Target folders.
To excluse all .jar files:
Click on windows icon/start menu
Type indexing in search box and click on Indexing Options
Then click on Advanced button.
Go through File Types tab.
In the list, find jar and uncheck it.
Turning off Window Search service on Win7 worked for me
The problem is eclipse is constantly reading the directories and artifacts in your maven project and inevitably has one of them open when you are cleaning.
The best approach is to run maven clean from the eclipse plugin (I use m2eclipse and this seems to work well).
Another approach that sort of works is to run mvn clean with the maven.clean.failOnError flag set to false. If you run it twice usually that is enough to make everything work properly, e.g.
mvn clean -Dmaven.clean.failOnError=false && mvn clean -Dmaven.clean.failOnError=false
You will probably want to turn off eclipse's "Build automatically" from the project menu while you do that.
Following are my findings -
Apart from IDE holding on to the jar, at times you will have some java process which could cause this as well. Lookup for any "java.exe" / "javaw.exe" process in task manager and kill it.
It helped me resolve this at times.
Often you run into this problem when on Windows because Windows doesn't (ordinarily) allow you to delete a file which is in use. Aside from (painfully) going through all your Maven configuration, your best bet is just not to build on Windows (e.g. use a Linux/Solaris/whatever VM).
I'm guessing you are opening files in a text editor or leaving a shell open on a directory in target. If some process has a lock on a file or folder Windows won't let you delete it.
If you run a tool like wholockme you'll be able to see what process is locking the file.
If you're using IntelliJ, you can pass an additional parameter in the Maven Runner settings:
-Dmaven.clean.failOnError=false
Set it here, in the VM options:
References:
http://www.jetbrains.com/idea/webhelp/maven-runner.html
http://maven.apache.org/plugins/maven-clean-plugin/faq.html
Windows Indexing Service, application server or IDE holding the JAR file is the root cause. Best solution is to disable Windows Search Service or exclude JAR files from indexing.
Another (imperfect) option mvn clean || mvn clean. Double pipe symbol runs second command only if first one fails.
See Releasing Windows file share locks for details on how to find and remove Windows write locks (it advises to use ProcessExplorer or Unlocker).
I had the same problem with builds run from Hudson.
Using handle.exe (from Sysinternals) I found out that a java.exe task has an active filehandle to the generated jar file.
If I kill this task the next build succeds.
But the next build after this successful build fails again with the same error.
Even if the build task succeeds, it seems not to terminate properly and keeps files open.
I'm a beginner with Hudson and I didn't have this problem at first.
Then I played with some plugins and later this problem come up and was reproduceable.
I deactivated almost all plugins (kept only some essential ones like subversion and sonar) and now the problem seems to be solved.
Hope this helps a bit ...
Try to disable Windows Indexing Service.
I had the same problem. I closed eclipse and looked at the running processes in task manager and seen one called 'Java.exe' which is not usually running so I ended it and then run 'mvn clean' again. It should delete the file properly and work correctly.
In my case, there is a java process which is executing the surefirebooter.jar which is the plugin to do the maven JUnit test.
So you can simply open the task manager and kill the java process.
That's because you block target directory (open a file or enter into (sub)directory of target dir, or any other process/app uses file from this dir). If windows delete command also complains it's not maven fault.
What I have found is that Java development with Maven on Window 7 struggles when the source code is on C drive. Moving my code to another drive works. Even a logical drive will work, the drive doesn't necessarily need to be a different physical hard drive.
If you don't want to change Windows Indexing settings, you can simply pause it, too.
you should close all the files in target ,for me i use M2eclipse directly is better you can also try mvn clean -Dmaven.clean.failOnError=false
The application which you are running should be stopped. Looks like the app is still running, while you are trying to clean the app.
The solution is restarting windows 7 .It helps to release the resources.