eclipse builds all projects even on issuing build for single project - java

There seems to be some issue with Eclipse VERSION 3.7
When I compile some single project ( though ant or though buildProject) , Eclipse starts building all projects in workspace and that takes a long amount of time.
I have tried building project in two ways -
right click ant file, select Run as And Build
Right Click project in Eclipse , select Build Project.
Both ways Eclipse starts building other open projects first.
is there any ways we can avoid it.

Three options I can think of:
Disable automatic building (Preferences->General->Workspace).
Change the build order to compile the project you need first (Preferences->General->Workspace->Build Order).
Close any projects you don't want built.
None of these is ideal, but they may be an improvement.

I have checked the options you have in the current Eclipse release, Indigo.
Use automatic building: See the Menu Project > Build Automatically. If that is on, Eclipse builds on its own only when there are changes to files, and it will build incrementally. I suspect that this option is off for you.
If the option is not used, you can start a build by doing Project > Build All or Project > Build Project. As the menu entries say, only the first one will build all your projects. Perhaps you are using the keybinding that starts that menu entry? CTRL-B? This will only do anything if something has changed.
When doing a clean build, there comes a popup (see below) with some options in it. If you set the right options, only the project you have selected will be cleaned and then built.
So only the options Clean projects selected below combined with Build only the selected projects will do what you want.
I do not understand why an Ant build (started in Eclipse) of one project will lead to a rebuild of all projects in the same workspace. There is no connection at all from the Ant build to the eclipse projects. The only reason I could imagine is, that the Ant build touches something, which is then dirty, and that leads to a new build. Perhaps you should add information about your build file, the directory structure you work on, ...

Shortcut Key Method
Another way is to change the shortcut key for building a project eg. Ctrl-B to only Build Project, instead of Build All.
Go to Window -> Preferences
In General -> Keys, find "Build" in the filter
There are two cases, Build All and Build Project.
Personally, I set Ctrl-B to Build Project by pressing Ctrl-B in the Binding Box
Next I set Ctrl-A Ctrl-B sequence to build all Projects
Try it out

Related

How to configure default project build in IntelliJ [duplicate]

Case in question: A Maven based project that has a Maven Run Configuration with its 'Command line' parameters defined as clean install.
Clicking the green arrow to invoke 'Run my_maven_config' downloads all necessary packages from Nexus and completes the build successfully.
Selecting 'Build Project' however, invokes a seemingly similar process but after building successfully for quite a while, it fails on a missing Hibernate package.
Why is this difference?
Shouldn't the build part of 'Run' be identical to the "standalone build"?
They are not identical. IntelliJ IDEA imports the external project model from Maven and converts it to the internal project model. It's not 100% accurate, some Maven plug-ins are not supported, some dependencies may fail to resolve, etc.
See this answer to perform the diagnostics. Try re-importing the project (delete .idea directory first if it doesn't help).
Delegating build/run actions to Maven as it can be done now with Gradle will be supported later (probably in IntelliJ IDEA 2018.3).
Now IntelliJ IDE allow to delegate Build actions to maven.
Go to Preferences and search for "Delegate IDE build actions to maven".
So when you build a project, IntelliJ IDEA invokes the appropriate Maven goals.

How to clean or clean build my Maven project in IntelliJ IDEA?

I'm using Apache Maven in my Java project. in NetBeans there are build and clean build icons but there aren't in IntellIJ IDEA. How can I clean or clean build my project in it?
Maven > Lifecycle > clean
Open the Maven Projects panel. Click lower-left corner for pop-up menu if that panel is not already visible.
In that panel, open the Lifecycle item. There you will find clean and install items for you to run.
As commented, you can also invoke this by command-line/console. But if already using IntelliJ, I do not see the point. Just show/hide this pane as you work. I use it countless times a day to hit install to build complete app, and hit clean whenever I suspect not all of the project is up-to-date in the build-results.
Build > Rebuild Project
If you are having weird problems in running the app in development also try the menu item Build > Rebuild Project.
I have asked what is the difference between a Build > Rebuild Project versus doing a Maven clean. But I still do not understand the precise details. So when things seem wonky, I do both to right the ship.
Tips:
Restarting IntelliJ may help when behavior seems odd.
Keep Intellij updated.
The answer here with the most votes suggests running the clean and install Lifecycle items separately in IntelliJ, which is easy enough and works. But it’s worth mentioning that you can combine these steps (and/or others) by instead creating a new Run/Debug Configuration of type maven and adding the command clean install (or whichever combination of maven lifecycle methods you run on a recurring basis).
Thereafter, running a mvn clean install is as simple as clicking the green button to run that Run/Debug Configuration.
Here is a faster way to do that:
in IntelliJ IDEA window hit Ctrl key twice, then a pop-up window appears like this:
there you can enter your command and use recommendation tools, too.
including template commands and the list of your previous ones:
In IntelliJ, go to your Toobar, View>Tools Windows>Maven Projects
From there, you can click Clean to clean the project
click on maven panel --> select project--> lifecycle --> double click clean.
source: vaadin.com
I have the same problem. I found some suggestions but nothing get me to an acceptable solution. Here are some things I found maybe it will help you:
File -> Invalidate caches / restart
or just rebuild the project: Build -> Rebuild project (Shift+F11)
But it's nothing like Clean or Clean and Build from netbeans.
By the way I use intellij-15.
Edit: Finally, Build->Build Artifacts->Build or Rebuild works for me.
So far, the best I can come up with (for a non-Maven project) would be to manually delete the target folder and then do your build. But I'm still looking for a better answer, myself.
I'm building a Maven project, and I discovered if I run the Maven Clean phase from the IntelliJ "Maven Projects" pane, it deletes the target folder. The target folder itself (without subfolders) corresponds to NetBeans' dist folder, and the subfolders in target have corresponding subfolders of the build folder in NetBeans. When you clean and build in NetBeans, the first thing that happens is the build folder and dist folder are deleted, and this corresponds to deleting the target folder in IntelliJ, so that's why I suggest it.
Note that just as you get an error if you try to clean and build in NetBeans while holding open a file that happens to be in the build or dist directory, you will similarly get an error in IntelliJ if you try to execute the Maven Clean phase while a file is open in the target folder - the difference is, if you are doing this in Windows, IntelliJ will half-way delete the folder and there isn't a simple straightforward way to clean up the mess even after you close the program that is holding the file open. Probably if you reboot it will clean up, but who wants to do that? I ended up identifying the culprit process (processes, actually - two copies of explorer.exe) with Sysinternals Process Explorer, killing all instances of explorer (killing only the two culprits didn't seem to work), then starting explorer back up via Task Manager, and everything was fine.
You can use the terminal to switch to the current project directory and use mvn clean install
If it's a Maven project:
Go to your project's root folder (where your pom.xml is located)
In address bar of windows explorer type cmd
You should be prompted with cmd window where you should type mvn clean
That will clean your target folder which is getting created after build
Make sure you have your system variables set so mvn commands can work (otherwise you will get "mvn is not recognized as an internal or external command")
This is how it should look:
Hope this helps.
As explained in Jetbrains help there are three ways to execute maven goals in IntelliJ.
One simple way to execute clean and install and also save the configuration is to select with CRTL button the goals "clean" and "install" from the maven tab -> Right click in one of the selected -> Modify Run Configuration -> check all the fields -> click OK. Then you can execute this configuration in order to clean and install.
This way works for the InteliJ IDEA 14 upwards not exceeding InteliJ IDEA 20:
Click Run -> Edit Configurations -> Press + -> Search for "Maven" -> Locate "Command Line" field and enter in following maven commands "clean install" -> Press OK.
Now click the green button to run that Run/Debug Configuration, this will maven clean install the module/project.
The output of the module if you are to deploy somewhere can be seen in the target directory in the project.
Maven Clean Install refers to clear any compiled files you have, making sure that you're really compiling each module from scratch

What exactly do the Maven build... choice inside the Eclipse Run As?

I am absolutely new in Maven and I am studying it. I am using Eclipse
I have the following doubt: into Eclipse I have a Maven project.
If I select this project and I do right click on it and then I select the Run As option I have some choice. What exactly represent these choice? Are Maven tasks or what?
In particular to perform my project I have 2 possible choices:
Maven build
Maven build...
What exactly does these tasks? It seems to me that build the project and perform the related unit test. Is it true or am I missing something?
What is the difference between the previous choices. In the tutorial that I am following it is used the Maven build... and then set the clean package as goals. What exactly do this goal?
Tnx
The Developing with Eclipse and Maven - 4.2. Running Maven Builds doesn't really give any clue about the "Maven build" command.
So:
the "Maven build..." allows to define a new run configuration
the "Maven build" allows to choose between the existing user's run configurations or to create a new one if none exists.
About a user's run configuration with "clean package": have you ever used Maven? May be a good tutorial would be a first step... In the mean time - those goals will:
delete the target sub folder
rebuild the project in the new empty target sub folder
generate the archive jar-s as specified in the project pom

How to launch ant clean target when executing eclipse Project clean

In order to simplify Eclipse use for our newbie users, we want to add this features to Eclipse :
1) If the user click on Project ---->Clean... , eclipse launches also the ant clean target which is implemented in the build.xml file of the concerned project.
2) When the user saves the code, the ant build is launched automatically.
Any link or a starting point.
Thank you in advance
You can add an Ant build file to the builders for a project in project Properties > Builders. Click New... and select Ant Builder. You can then specify the build.xml and select the targets used for clean, manual build and auto build (run during save).

Want an eclipse java project to run ant build files automatically

I have an Eclipse Java project, not a plugin project. And the project has some external dependencies that I handle in two separate ant files. Everything works fine, but I want to force Eclipse to run the ant files everytime it builds my project.
How can I do that?
If this had been a plugin project I would have handled it in a customBuildCallbacks.xml and included it in my build.properties, but doesnt seem to work when its just a java project
Step 1: Add the build file to your ant view
Click the add button and select the build.xml file from the project. You can also drag the build.xml file onto the ant view (To add the ant view to your perpective, go to Window > Show View > Other…)
Step 2: Run as Ant Build
In your ant view, right click the newly added build file and select Run As > Ant Build… In the dialog window, select the ‘Hide internal targets not selected for execution’ option in the Targets tab. You can rename the builder in the box at the top of the window if you wish (I usually remove the trailing ‘build.xml’. Click Apply and Close.
Step 3: Setup automatic build
Right click on the project, select Properties, then Builders. Click Import. Before closing the screen, highlight the imported build and select edit. Go to the Targets tab select clean for ‘After a clean’ and deploy.local for ‘Auto build’. Apply the changes and close.
Step 4: Enable Auto Build
Go to Project > Build Automatically
source: http://www.simonwhatley.co.uk/using-ant-with-eclipse
Go to your project properties, select "Builders", and add a new Ant Builder. You may specify which targets to run at what time (during a clean, after a clean, etc.), and which resources (if any) to refresh in Eclipse after your ant target is executed.
Project/Builders/New/Ant Builder
There you can add your custom ant build.
At least with Eclipse 4.2 (Juno), the ability to auto-build with Ant has been removed. Under the builder configuration -> "Auto Build", there is a message: "". That said you, can still work around this by:
Follow the steps above for creating your Ant builder. This will create a file in projectDirectory/.externalToolBuilders.
Modify projectDirectory/.externalToolBuilders/YourLaunchName.launch:
You'll need to add auto, to this line: <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
Specify the target you want run for auto by adding: <stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="compile-jar,"/>
You can look at your Ant builder configuration and see that everything looks good:

Categories