Eclipse Maven Build and Test with One Button - eclipse

The most common build activity I do in Eclipse (other than allowing auto-build to do its thing) is to perform a "Maven Build..." with parameters of clean and package. This runs all my tests. m2eclipse does a great job with this, and I like the output. If a test breaks, I then jump to using the JUnit plug-in, the debugger, etc.
I've used "Organize favorites..." under the Run (and Debug) button's drop down menu to make this kind of build "permanent" and somewhat easy to access and use.
But not easy enough.
What I have now is a button that morphs from moment to moment, based on my last activity, what file I have open, or what item I have selected in the project window. Yes, I can click the down-arrow next to the run button, select the favorite for "clean-and-package" but for something that I do hundreds of times a day, that's too difficult.
I want ONE BUTTON. A big ol' button on the tool bar that I just click and boom goes the dynamite. I'll also accept a way of assigning a hot key to my build favorite so I can press, say, ctrl+r or something to run my favorite item.
What'cha got for me?

I've rediscovered key bindings in Eclipse. It's not exactly what I want, but it works well enough, I suppose. I simply bind F7 to Maven's test hook. It's not the same as "mvn clean package" but it'll do until I find a better solution.
Here's how I did it:
Open preferences
Open General->Keys
Search for "maven test" (or "run maven test")
Select the Run Maven Test entry
Click on the field labeled Binding
Press F7 (or whatever keystroke you want to bind)
Probably best to set the When field to in Windows
Now, when you press F7, eclipse will run "mvn test".
For whatever reason, and I'm sure it's a perfectly good one, the m2eclipse plugin authors didn't provide a "Run Maven package" hook. Sigh.

It looks like there's a couple of ways to do this - none directly in Eclipse:
Create your own small plugin that defines the key binding, see here: eclipse: put keyboard shortcuts on specific launch configurations
Use Practically Macro - also see here: Assigning a keyboard shortcut for a specific Eclipse build configuration
Use some form of scripting, e.g. this: http://mackaz.de/72

If you create a Maven Run Configuration and put a number as the first character in the name, then you can use Shift-Alt-X Ctrl-M N, where N is the number you gave as first character in the name. For your case, do the following.
Right click on your project, select Run As and then select Maven
build... This will open a dialog to create a new Maven Run
Configuration.
Make the name of the configuration 1 - test.
Put test as the goal.
Press Apply and then Close.
Type Shift-Alt-X Ctrl-M 1. This will select the configuration you just created.
Press enter will launch it.

Related

How to customize sikuli x ide?

I want to customize Sikuli x IDE. Like changing the title in title bar. I found the code on gitHub for Sikuli IDE but cant make out which line refers to the title. And how to run that in Eclipse.
I am not sure what specifics you want to change on the IDE, but you mention running it in Eclipse. So if you prefer the Eclipse layout, you can code SikuliX projects from Eclipse directly and skip needing to modify the Sikuli IDE.
Get PyDev from Eclipse Plug-ins/Marketplace
Window->Preferences->PyDev->Interpreter - Jython
Click "New..." button and add your jython.jar and click OK
The System Path window there will be populated and if it does not include sikulixapi.jar, click New Jar/Zips and add that as well.
Apply/OK
Repeat for Python interpreter as well
You will lose the ability to see images in the project.sikuli folder within the IDE (as far as I know) as well as to take snapshots or define regions using the IDE buttons. However, if you were looking to customize your own IDE, those features may be out of scope for your application anyway.

Does eclipse have a debugger "step into selected" option that prompts for the method to step into?

I have used IntelliJ Idea on a few projects and I really like the feature it has in the debugger where I can step into a line of code, but choose which of the methods I REALLY want to step into, instead of going through them all until I hit the one I want.
For example, the debugger stops at this line:
String restult = getMyResult(getParam(), buildSomething(), nextOption(x));
I want to hit ctrl+F5 and have a list popup with:
getMyresult()
getParam()
buildSomething()
nextOption()
and I can select getMyResult and step into that method while skipping the other three.
It sure miss that feature when I am debugging in eclipse, does anyone know if there is something comparable?
I know about the Step Filtering options in Eclipse, but that is not quite what I want.
You can simply put a cursor on method you want and hit Ctrl-F5, so no additional selection needed.
Alternatively you can use Ctrl+Alt-Clik using mouse do do the same.
You can:
Select the text of the method call you want to jump into
Then right-click into context menu
Choose "Step into selection" from there.
Does not work all of the time tho.
In IntelliJ Idea 10.5
It is called Smart Step Into
In menu it can be found "Run -> Smart Step Into"

Eclipse: shortcut for "open project"?

Is there a shortcut in Eclipse for "open project"? Ideally, I'd like something like the "Open Resource" dialog.
I want this because I have a "testing" project, which I use whenever I want to try something out… But it's annoying to scroll through the massive Navigator trying to find it and click it when it gets closed.
Not by default. The action is defined here, with no keyboard shortcut.
http://eclipse-tools.sourceforge.net/Keyboard_shortcuts_(3.0).pdf
You could add a Working Set that contains only your test project, and use 'Select Working Set...' functionality from the Navigator tab's view menu:
While this won't open the project for you, it WILL make it the only thing you see in navigator or package explorer.
Once you've added it, it will be in a list and you won't need to open the 'Select Working Set...' dialog, just select 'my test project' from the popup menu. It's triggered by that small triangle in the upper right of Navigator, I'm not sure if there is a shortcut.
To switch back to your normal work, simply 'Deselect Working Set' and you will then see everything again.
I also find the 'Collapse All' button/shortcut to be handy when finding things in the Package Explorer or Navigator tabs.
I'll offer a solution to a problem I've had which, if I've interpreted the question correctly, is very similar to yours.
I find that when I have a lot of projects with loads of expanded directories/packages inside Project Explorer, trying to find a particular project is irritating because I have to scroll through all this. I could collapse all projects down but then I also lose my current position in every project.
I'd just like to be able to search for a particular project by name and open it, in the Project Explorer tree. Opening a file inside the project using Open Resource isn't a good enough workaround, as having to think of the name of a file inside that project completely out of context is often equally annoying!
A solution that works great (at least in Eclipse Juno, Mac OSX) is, with the Project Explorer focused, to hold Shift and start typing the project name. This dynamically selects the best matching project in the Explorer as you type. Then with your hands still on the keyboard you can use the arrow keys to open up and browse the project.
It ain't pretty but it gets the job done, and saves some valuable seconds :)
You could also:
switch workspace (in a workspace with only this test project in it) (no shortcut: you can define one)
install mylyn and select a "test" task (which would immediately empty your Navigator view, leaving only the relevant classes/methods).
If the test project is already opened and you know the name of the class in it, you could go to this class with Navigate -> Open Type (There is a shorcut also, on mac osx is Shift + Command + T)
I find it easier to move with this method, but I didn't know it until someone else showed me, maybe it helps.
You can set a shortcut at Preferences->General->Keys, search for Open Project. However, for me it does not work from the editor itself. I have to click the package explorer, for example. Also, if you have a lot of projects, there will be a huge list of them as well, as expected.

How do I limit task tags to current project in Eclipse?

Eclipse currently shows the task tags (// TODO) from all open projects. I would be grateful if anyone could point out the preference, where I could restrict the scope of tasks displayed (e.g. only tasks from current project).
In Eclipse Helios (3.6) you can configure the scope.
Down arrow at the top right -> Configure Contents:
Select a configuration on the left (or create a new one) and on the right in the Scope section select "On any element in same project".
There should be a down arrow in the top-right with several options in it. For the old Eclipse the option you want is Filters... And for the newer Eclipse the option is now Configure Contents. At the top of the Configure Contents dialog is a scope selection with options you want, I think.. If not check preferences and search for tasks, or scope. It should be in there somewhere.
Close projects that you aren't working on. Tasks show for any part of the workspace, so remove projects that you arent working on by doing a close operation. (right click on the project in the project explorer and then "close project")
Configure Contents... can be used to filter to things like working sets (if you're not already using working sets, you should), but yet another way is to use Mylyn to filter out any UI elements not relevant for what you're currently working on.
In Eclipse 2019-06:
1- Open the Tasks window.
2- Click on the arrow pointing down ▽.
3- Click on Filters...
4- In the Configurations panel on the left select TODOs (or any configuration that you have saved).
5- Under Scope select On elements in selected projects
6- Click on Apply and Close
Now the task view will only show the tasks of the project where you are at the moment.
Simply close the projects you are not working on.
You can leave them in the workspace, too.
In Eclipse Juno 4.2.1, I found that it's possible to disable specific projects TODO tasks.
In the projects properties open:
Java Compiler > Task Tags
From that page check the option "Enable project specific settings" and remove the TODO entry from the list below, after that the TODO comments from that project won't be shown in Tasks.
You could also remove other tags from the list.
Filtering by working sets works fine, but I had to put the packages into a working set, rather than the whole project.
AFAIK the Eclipse task list is workspace-based and cannot really be filtered by default.

Eclipse 3.4.1 - how to view compiler output in Console while building a project

I have what appears to be a very annoying problem. When compiling a project in Eclipse, I see no Console that shows the invocation of the Java compiler and the build results (as in NetBeans).
If I, for instance, import an existing project into Eclipse and invoke Project->Build Project, is there a view that will show me results of the compilation? While I know that my project contains a number of files that have errors, invoking Build Project shows no visual result/progress of the compilation. It does not show the list of errors so that I can quickly jump to them.
I'm aware that there is a "Problems" view, which shows a list of problems (and not just compiler errors) in all projects and not the particular project that I am working with, which makes it very inconvenient to locate and jump to source of the problem.
You can configure the problem view to show only problems in the current project:
Click on the small triangle at the far right of the view.
In the popup menu, select "Configure Contents..."
Select each item in the "Configurations" list and click on "Scope: On any element in the same project"
If you want to see the compiler working, you need open the "Progress" view.
Since Eclipse JDT provides its own built-in Java compiler, you generally do not see the invocation of Java Compiler.
The built-in Java compiler is tightly integrated with Eclipse and JDT, and provides the source indexing that enables powerful IDE features such as refactoring and quick fix.
Plus, it enables incremental build in background after each file modification, hence no visible "java" invocation.
You can replace/complete the java compiler with a javac` call of your own:
For instance, Using Alcatel-Lucent nmake with Eclipse JDT does precisely that, and uses a configuration launcher (which you can instruct to show a console):
You will need to add that special builder in the "builder" section of your project.
Do not forget you can create many "Problem view", and set one of them to show only problems for your current project.
Select: "on any element in same project"
Goto Windows->Show View->Console
or
Alt+Shift+Q,C
Console appears in tab with Problem view
Your question contains a couple of assumptions that you might want to re-think.
It does not show the list of errors so that I can quickly jump to them.
Errors are flagged in the edit window while you are editing. You can fix them on the spot, without having to "jump" anywhere.
If you drop an entire source file into your project, you may not be in an edit window on that file. (And, of course, that's not standard Eclipse usage.) The simplest way I know do deal with that is simply to "Refresh" the project and look in the Package Explorer view to see whether there are any errors detected (which will happen immediately if you "refresh" a file into a source folder). Double-click on any files which show an error icon and look at the right-hand side of the edit window to see exactly where the errors are.
I'm aware that there is a "Problems" view, which shows a list of problems (and not just compiler errors) in all projects and not the particular project that I am working with...
Unless you are using multiple projects, with inter-project dependencies, I find it useful to close all but the current project on which I'm working. Then the "Problems" view is specific to the current context.
Finally, I'd recommend looking at the Mylin "getting started" page for other hints on how Eclipse can help you focus on the current task.