Run "mvn clean install" in Eclipse - eclipse

Title says it all.
I want to run the console command mvn clean install on my project in question directly in Eclipse, not from the command line.
It would just be more convenient for me to do this, as I already have the project open in Eclipse. It would save me time if I would not have to navigate to the folder in Windows Explorer.
Not a big deal if I can't do this... but can I? And if so, how?
It would be great if I could just right click my project, then click "mvn clean install" from the context menu.

I use eclipse STS, so the maven plugin comes pre-installed. However, if you aren't using STS (Springsource Tool Suite), you can still install the m2Eclipse plugin. Here is the link:
http://www.eclipse.org/m2e/
Once you have this installed, you should be able to run all the maven commands. To do so, from the package explorer, you would right click on either the maven project or the pom.xml in the maven project, highlight Run As, then click Maven Install.
Hope this helped.

Run a custom maven command in Eclipse as follows:
Right-click the maven project or pom.xml
Expand Run As
Select Maven Build...
Set Goals to the command, such as: clean install -X
Note: Eclipse prefixes the command with mvn automatically.

You can create external command Run -> External Tools -> External Tools Configuration...
It will be available under Run -> External Tools and can be run using shortcuts.

Right click on pom.xml, Run As, you should see the list of m2 options if you have Maven installed, you can select Maven Clean from there

If you want to open command prompt inside your eclipse, this can be a useful approach to link cmd with eclipse.
You can follow this link to get the steps in detail with screenshots.
How to use cmd prompt inside Eclipse ?
I'm quoting the steps here:
Step 1: Setup a new External Configuration Tool
In the Eclipse tool go to Run -> External Tools -> External Tools Configurations option.
Step 2: Click New Launch Configuration option in Create, manage and run configuration screen
Step 3: New Configuration screen for configuring the command prompt
Step 4: Provide configuration details of the Command Prompt in the Main tab
Name: Give any name to your configuration (Here it is Command_Prompt)
Location: Location of the CMD.exe in your Windows
Working Directory: Any directory where you want to point the Command prompt
Step 5: Tick the check box Allocate console
This will ensure the eclipse console is being used as the command prompt for any input or output.
Step 6: Click Run and you are there!! You will land up in the C: directory as a working directory

Just found a convenient workaround:
Package Explorer > Context Menu (for specific project) > StartExplorer > Start Shell Here
This opens the cmd line for my project.
Unless someone can provide me a better answer, I will accept my own for now.

Related

Running Jason applications in Eclipse

When I want to run my .mas2j file in Eclipse, I always have to right click the file and then select "Run as Jason application". Is there a way to add a shortcut to do this?
Jason's "Run" button should be added to eclipse toolbar ("Step 14" of jason eclipse-plugin installation guide) and it is supposed to work. Anyway, you can save some time using shell, following instructions in jason's github page:
git clone https://github.com/jason-lang/jason.git
cd jason
gradle config
And run a project using a command like bellow:
jason examples/gold-miners-II/miners.mas2j
Another way, and actually my recommendation is moving to JaCaMo (which has Jason embedded). JaCaMo offers a gradle script for your projects. You can easily download JaCaMo from the repository and create a project from zero in one shot (first, go to your project root folder and then type):
curl -s -O http://jacamo.sourceforge.net/nps/np07.gradle
gradle -b np07.gradle --console=plain
After downloading JaCaMo, the script will ask you to type a name for your project, for instance, "test". So, go to "test" folder and type:
gradle run
The just created JaCaMo project should launch after this command. Besides good compiling performance, another advantage is that gradle will manage package dependencies.
This is usually the issue with uncategorized commands in Eclipse. I had the same issue with the Run JaCaMo Application option. In order to see all your plugin commands:
Go to Preferences -> General -> Keys. Click on Filters... and de-select Filter uncategorized commands then Ok.
Then you should be able to find the desired command in the Command list and add a preferred Binding.
Note: If Eclipse offers a command, it should be listed in the pop-up window that appears when hitting the Show a table of all available commands button of the Oomph toolbar. The table shows all the available commands, where you can find them, and all the defined shortcut keys.

Run as Ant build' Missing in my eclipse

I am unable to right click and run my build.xml file by choosing 'Run as Ant' . Whenever I click it says run configuration and that goes into running Java file options .
This works for me.
Go to..
1. Help -> Install New SoftWare
Work With -> "http://download.eclipse.org/releases/juno"
Drop down list "General Purpose Tools"
select "Eclipse Plug-in Development Environment"
After doing this...eclipse started showing option of Ant Build in Run as
In Eclipse Neon, the Ant Build moved to Run > External Tools > External Tools Configurations ... it is not located in the default Run anymore.
An example of a build xml file and how to run it
I hope this helps!
I encountered a configuration where depending on the filename of build.xml file the "Run As" menu did not contain the "Ant Build" and "Ant Build..." commands. The commands "Ant Build" and "Ant Build..." (see the image in ricardoramos's answer) are present if the build file is named build.xml, but absent if the file is named build-something.xml.
I tracked down that the cause of this issue in my configuration was plugin LiClipseText. Uninstalling the plugin resolved the issue. I observed this with LiClipseText version 2.1.2 and with Eclipse versions "2018-09" (4.9), "Photon" (4.8) for Java EE Developers.
The plugin provides its own editor for XML files, and I guess that interferes with the way how Eclipse detects that an XML file is an Ant build file.
It may be that this will be fixed in a future version of LiClipseText.
For a recipe on how to uninstall the plugin - see question 6174725. For a cleanup afterwards - see question 221476.
Another possibility is your build.xml file is not parseable by ant
For example, if you open the Ant Perspective (Open Perspective | Other | ant) and then choose the Add Buildfiles toolbar button, then choose your build.xml file, if it is not a valid build file, you may see an error message "Unable to parse as an ant build file".
Once you fix your build.xml file, the Run As ant RMB command on the build.xml file will appear.
(above was my experience on Eclipse Mars.2)
Follow the below steps.
Go to Windows -> Preferences -> General -> Content Types -> Text -> XML -> Ant BuildFile.
Just click on Add button and add your AntBuild file. click ok.
Restart your Eclipse.
Follow the below steps.
Go to Windows -> Preferences -> General -> Content Types -> Text -> XML -> Ant BuildFile.
Just click on Add button and add your AntBuild file. click ok.
Workaround:
Open the ANT-View, add the build file and start it from there.
(Had the problem in JBDS8 after installing IBM Diagnostics Tools)

GWT ant devmode:ant is not recognized as an internal or external command

I am following GWT tutorial from code.google.com. I build an application using webAppCreator & try to run it from command line using ant devmode. It raises this error, ant is not recognized as an internal or external command
Try using the eclipse plugin. You can download eclipse for free by clicking here
Then click "help" and "install new software". Enter this link: http://dl.google.com/eclipse/plugin/3.6
Just click next, next and restart eclipse.
If you really want to use the command line you should add your sdk path to your computer variables but I don't know the exact setup anymore.

Launching run configuration outside Eclipse IDE

I have a run configuration defined for my Eclipse RCP application which is saved to a .launch file. Is there a way to use this launch configuration outside the Eclipse IDE? i.e, it would be nice to be able to launch the application from the command line for continuous integration purposes.
You can get the command line Eclipse uses:
Run your program in Eclipse
Go to the "Debug" view
Right-click on the process (probably the second item in the tree) and select "Properties"
Copy shell command and delete the agentlib flag to run in bash. Unfortunately, you need to do this whenever you change the configuration.
Yes, you could create and export a product configuration based on your launch-configuration:
Create new Product Configuration (File -> New -> Other)
Name the file (e.g. myrcp.product)
Select "Use a launch configuration" on the first page of the wizard
The product editor should open automatically. In the Exporting section you should be able to export your product using the "Eclipse Product export wizard".
Resource: Eclipse FAQ - How can I deploy my RCP app
Have a look at this PDE Build tutorial. It explains how to build and test (or run) your product using Ant.
It is possible to do that with a little workaround. You can find your configuration at workspace\.metadata\.plugins\org.eclipse.debug.core\.launches. So, open it in text editor and find an attribute containing goals, e.g. clean install -DskipTests=true.Then, go to the root of your project and execute that by the CMD:
mvn clean install -DskipTests=true
This should be similar for other goals.

How do you run the maven-gae-plugin "mvn gae:run" command from inside Eclipse?

From the command line, the maven-gae-plugin can be run by calling:
mvn gae:run
I am working in a Maven project with a POM file that declares the use of the maven-gae-plugin.
I can run this maven command from the command-line in Windows. But, after setting up the source code as a project inside Eclipse, I don't know how to run this command from inside the Eclipse IDE. Is this possible?
Assuming you're using m2eclipse, right-click on your Maven project, go to Run As → Maven Build… and create your Run Configuration for a Maven Build. Here is an example:
This configuration would run the gae:run goal on the selected project.
To access it later, right-click on a Maven project and go to Run As → Maven Build (without the …), then select the launch configuration.