Clean and build an Eclipse java project with one click - java

Is it possible to clean and build a java project in Eclipse with one click? I don't want to go to Project -> clean -> OK and than to project menu 'Build project'

In Project->Clean I select "Clean projects selected below", select my project(s) and check "Start a build immediately" with "Build only selected projects".
Then go to Window->Preferences->General->Keys, search "Build clean" and enter my own binding for this command. For example, Ctrl + D.
Then, when I press Ctrl + D and Enter I have clean and build.

When you have
Project --> Build Automatically
checked, it will be automatically rebuilt after cleaning it.

If you need something more powerful than clean and deploy, I suggest to learn Ant build tool.
http://ant.apache.org/
Just configure it for your project and prepare the build script, than configure the build script for the clean and build target. If you need, also to deploy it on your server (glassfish, weblogic or whatever you want). With Ant you can configure more situation (test, production..)

Select your project and goto menu bar:Select Windows then->Select Preferences then ->Select Keys then ->Select Build and Clean

Just need to Ctrl + S then Build, it will be as good as new!

Related

Import Maven projects automatically checkbox dissapear in IntelliJ EAP

I use to use IntelliJ, lately I have updated to IntelliJ EAP now the checkbox "Import Maven projects automatically" has dissapeard , so every time I add a new dependecy I need to do it manually.Is there any other way or work around to have this checkbox visible again , or to enable auto import?
Thanks
Search "Enable auto-reload after any changes" in the action dialog.
They have renamed and relocated the functionality to the Maven tool window as a control with the latest version.
By following ways you can Import Maven projects automatically:
For InteliJ IDEA 14 upwards:
Click Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing -> TICK "Import Maven projects automatically".
For InteliJ IDEA 2020 upwards:
Click Settings -> Build, Execution, Deployment -> Build Tools -> TICK "Reload projects after changes in the build scripts" and "Any changes"
"We’ve also removed the option to enable/disable auto-import from the settings, as the improvements mentioned above have made it redundant."
https://blog.jetbrains.com/idea/2020/01/intellij-idea-2020-1-eap/?_ga=2.209144210.1862481759.1584865190-1304159286.1579103926#maven_and_gradle_importing_updates
They have added now in build tools -> select Any changes for reload project after changes in the build scripts.
Press ctrl + shift + a to open the "actions" dialog.
From there, type "import maven projects automatically". Click that option and it should work.

Eclipse: Add Maven configuration to quick links

If I define a maven config in "run as->run configurations" and then set one up, how can I then make it appear in the right-click -> 'run as' options?
Or failing that, where can I make the run configuration appear where it's not so buried in mouse clicks?
The moment you convert your project into Maven through rightClick-->configure and then update maven project you can automatically see maven clean in Run as option. From there you can build your project

Maven Build in Eclipse without using Command prompt

I created the maven-spring project using the m2e plugin of eclipse. The project is working fine. I want to do a Maven build in Eclipse the project without using any commands in command prompt i.e. using the eclipse IDE only. But I am not able to find the option for Maven build from Eclipse IDE.
Below are the options I am getting when I right click on my project:
Kindly advise.
you can follow this link, right click maven project -> run as -> maven build..
http://www.tutorialspoint.com/maven/maven_eclispe_ide.htm
Right-click on pom.xml, then go to the "Run As" menu (not the "maven" menu). The various plug-in goals (and lifecycle targets) are documented here.

Compilation unit is not on the build path of a Java project

I joined an SVN server and checked out the source files a project from that server. In the Eclipse editors, when I hit Ctrl + Space, I got the following error message:
This compilation unit is not on the build path of a Java project
What should I do to solve this problem?
Read this guide on how to use maven projects with eclipse
http://maven.apache.org/guides/mini/guide-ide-eclipse.html
Taken from the above link :
Reason why you get that notice :
Eclipse needs to know the path to the local maven repository. Therefore the classpath variable M2_REPO has to be set.
Solution
Execute the following command:
mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
Restart your Eclipse IDE (if you already have it open) for this change to take effect.
You can also define a new classpath variable inside eclipse: From the menu bar, select Window > Preferences. Select the Java > Build Path > Classpath Variables page
For Simple Projects :
If you have a simple java project which is made up of only one module, using eclipse is very simple. To generate the eclipse project files from your POM you execute the following command:
mvn eclipse:eclipse
If you have created or checked out the project with eclipse, you only have to refresh the project in your workspace. Otherwise you have to import the project into your eclipse workspace (From the menu bar, select File >Import >Existing Projects into Workspace). In the latter case the project (directory) should not be located in your workspace, because eclipse might come into trouble, especially if you want to use eclipse as the scm client.
For a more detailed explanation refer the above link.
Import project as maven project.
File-> import-> Maven-> Exiting Maven Project-> Next-> Root Directory-> Browse your project from Disk
Follow these steps:
Right click project in Eclipse. Select to Run As → Maven build...
In Goals add eclipse:eclipse
Select Run
Wait for build to finish
Right click project in Eclipse. Select Refresh
This is due to the issue in build path .
If you had imported the project as Existing Maven project, do the following to resolve the issue.
Right click in the Package Explorer -> Maven -> Update project.
Or select the project in package explorer and perform Alt+F5 which is the shortcut for the maven project update.
Execute mvn eclipse:eclipse on command line and once the build is successful, refresh your project in eclipse. This resolve the issue.

How to execute maven tasks in eclipse (Sonatype plugin)

I know it must be something simple, but I just can't figure it out..
I'm using the Sonatype maven plugin on eclipse. When I want to build a war file for a webapp project, the only way I know to do it is to use the command line and type mvn package.
I've looked all through the right click menu and I can't find any way to do it from eclipse.
There's a maven submenu that seems to have no options to do with building, and there's a run menu that doesn't seem right - I don't want to run my project - I just want to build it. There is a maven build option in the run menu, but if I run it, a configuration window pops up for me to enter goals in..
How I do I just do a simple mvn package, but through gui? What am I missing?
Thanks!
Thanks guys!
Both responses answer my question..
Now I have new problems that the build doesn't work, but I'll post that in a new question.
Take a look into the menu under that "Run As" there you find "Maven build" with a dialog where you can define different goals etc.
If your project is a Maven project, right-click on your project and select Run As > Maven Build to create your own configuration (goals, profiles, etc) or use one of the preexisting configuration.
http://www.imagebanana.com/img/ja7wh7m0/screenshot_008.png
Once you've run a Maven Build Run Configuration, it will also be listed under the "Run As..." green arrow:
alt text http://img8.imageshack.us/img8/8510/screenshotrun.png
You could add it as favorite if you want.

Categories

Resources