eclipse: plugin to call Maven - Update Project - eclipse

I'm trying to write a plugin to call the command that is executed when you Right click on a Maven Project and select "Maven" > "Update Project".
(This is part of a bigger plugin)
I can get command Service and from that I understand I can call ...
commandService.getCommand("org.eclipse.m2e.core.ui.command.updateProject")
To get the command, but how do I control what project it is executed on?
Can someone point me in the right direction please.
Thanks
Jeff Porter

You want to create a parameterized command from your existing command. See the Eclipse wiki for Executing a command with parameters.

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.

Can't run groovy script in Groovy Grails Tool Suite

I installed Groovy Grails Tool Suite Version: 3.5.0.RELEASE on a Windows system.
I have created a new 'Groovy' project using the eclipse Groovy project wizard. My project contains one script called 'HelloGroovy.groovy'. When I right click on my script, and choose 'Run As', I do not see any option to run my script except for 'Run Configurations'. I want to see a groovy script option instead. Is there something I need to do to set up my ide further?
I believe your problem is that you have a space in the path to your workspace. I just tried recreating your situation and when there is no space, it works. When there is a space (e.g. C:\Documents and Settings\Foo\Bar\workspace) the menu option doesn't show. I raised https://jira.codehaus.org/browse/GRECLIPSE-1737 to cover fixing it.

Run "mvn clean install" in 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.

Debug Solr code in Eclipse

New to Eclipse and Solr, I imported apache-solr-3.6.0.war into Eclipse and run Solr with tomcat plugin. Now i want to debug some existing code, however how do i import the Solr source code?
Without knowing how you imported it exactly: sounds like you are looking for Source attachment.
It might be better if you use the Solr source code directly. Check the README file included in the release, there is an ant task to init eclipse:
To setup your ide run [...] 'ant eclipse'.
Then all dependencies are loaded using ivy and you can run it from within the IDE.
You can also check out the whole Lucene/Solr source:
install Subclipse add-in
choose New... > Project...
SVN > Checkout projects from SVN...
add this link as new repository
select branch /branches/lucene_solr_3_6 (if you want last stable version. Use trunk if you want to use cutting edge source)
choose Check out as a project in a workspace and leave everything else default
Then, after the checkout completes, to complete setup, you don't have to fiddle with JARs manually, simply:
right click on main build.xml, the one in your project's root
choose Run As... > Ant build... select (in this order)
ivy-bootstrap and resolve tasks (which will download all JAR dependencies)
then run in this order: validate, clean-idea, eclipse, compile, get-maven-poms, generate-maven-artifacts (the last two only if you plan to use Maven).
And that's it, you should now see no redness in your workspace and have Lucene and Solr JARs built.
Run solr like this:
java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044 start.jar
Solr will start, but wait you to connect from Eclipse to continue.
Then in Eclipse, go to:
Run / Debug Configurations...
Select Remote Java Application
Press New button to create a new remote configuration
put 1044 on port
Click on Debug
This is the standard way to debug remote applications in Java
./solr start -p 8983 -f -a "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=0.0.0.0:8000"
Start solr with
provide app run on port 8983
provide Xrunjdwp:transport=dt_socket
remote ip address 0.0.0.0:8000
and then go to eclipse

Unable to run a Subclipsed Groovy script in Eclipse

After installing the Groovy plug-in in Eclipse, clicking Run brought up a list: Groovy Console - Groovy Script - Java Application. I'd select Groovy Script and it would take off.
Now, after checking out a colleague's Groovy project with Subclipse, opening a script in it, clicking Run brings up "The selection cannot be launched, and there are no recent launches".
Selecting Run As... shows '(none applicable)'. So I select Run Configurations... and click Groovy Script, but the Run button stays dimmed. Eclipse evidently needs more info, but what?
I suspect your colleague didn't check in the .project file. It contains the "nature" that defines the project as being a Groovy project. I don't know for certain but it is not uncommon for eclipse actions to be predicated on the presence of an appropriate nature.
I would also check the .classpath is present and valid as it should contain the Groovy libraries required to compile and run your script.
Assuming they are missing, get your colleague to add them, and after syncing you should be good to go.