Detect error in Eclipse Ant builder - eclipse

I have defined a custom builder for an Eclipse project (Project -> Properties -> Builders -> New ...)
The task that the Builder does is not important, since it is working correctly.
The problem is then: what happens if, for example due to the configuration of the developer, such Builder fails? An error is shown in the console, but the project is not marked as "failed". I would like the project to be marked as failed, since the developers are used to watch for red crosses in the Package Explorer and not to proceed if they see it.
Can I somehow configure the builder to do so? Any idea how? Any workaround?
Thanks,

The Laid Problem Marker plug-in is a tool for creating problem markers from builder output.
The plug-in adds a Problem Markers tab to the build configuration dialog for Program builders and Ant builders.
Screenshot:
A custom build output parser can be created either with a regex or by implementing a parser in Java. The parser is passed the console output from the builder, and the result from the parser is used to put problem markers on project resources that appear in editors and the Problems view.
See to project description for details.
The plug-in can be installed using the Install New Software GUI from the project update site:
https://bitbucket.org/lii/laid_language_tools/raw/master/se.lidestrom.laid.update_site/
Disclaimer: I am the project author.

Related

Create plug-in that creates a snapshot of the source code currently opened on editor - Eclipse CDT

I need to create a plug-in for Eclipse CDT that sends a "snapshot" of the source code of the currently opened editor each time the code is "built".
I am already capable of doing it each time the user presses a custom button created by me, but it would be great if it could be done when the "standard" "build" action is performed.
Do i need no create a plug-in of the type "builder"?
I am using Eclipse 4.4.0...
Can someone help me?! (Sorry for some english mistakes... :( )
One solution would be to create your own custom "Builder". Instead of actually building the code, it would invoke the functionality you already have.
For information on how to use the eclipse build system, please have a look here: https://wiki.eclipse.org/Eclipse/FAQ/How_do_I_implement_an_Eclipse_builder%3F.
Also, this website goes into more details about building in eclipse: https://www.eclipse.org/articles/Article-Builders/builders.htm. However, I think that the first one should do.
As a side note, this works with any kind of eclipse project (JDT and CDT). The build described there is common to all flavours.
Hope it helps,
-Caius

Where should I look at in Eclipse source code to figure out how Eclipse generate JUnit testing result?

I'm analyzing Apache ant source code for my research. When a test suite runs, test cases are executed and Eclipse shows the test result as the image below. My goal is to get the executed test case names as Eclipse does. If I can see source code where Eclipse handles this, I think I can get the name list. Therefore, I'd like to know the source code location where Eclipse handle this or an easier way to achieve the goal... I tried using JUnit task in an ant build script to generate the test report so that I can get the test list by parsing the text/xml report. I could get the report with some warnings stating that duplicate classes are detected because I'm testing ant with ant. However, the report showed the test method name without its full class name...
Well, there is a short workaround for what you want to achieve (to have a specific, deterministic test run order), it is the #FixMethodOrder annotation on your test class. That will make your tests run in a specified order in every environment (or at least it should :-)).
If you want to do it in the hard way (analyze the source code of the Eclipse JUnit runner), I would advise installing the PDT tools and sources of the plugins first, and also set the Include all plug-ins from target in Java search under the Plug-in Development options (so you can find the plug-in types easily with Ctrl+Shift+T/R).
Then you have the Plug-in Spy which is a rock of a feature: press Alt+Shift+F2 and click on any element on the UI. Then you get all the info where the given component in defined (alternatively, you can press Alt+Shift+F1 zo display data of the selected component). An example is below:

Jad/JadClipse for Scala?

Is there something equivalent or similar to Jad/JadClipse for Scala? It would be nice to be able to view the source for Lift from within Eclipse via "Open Declaration".
I don't know of any decompiler, but I think what you want to do just attach the source to the jar containing classes.
Just right-click on the lift-jar in the package explorer and choose properties. There you can specify a source location. I believe that an attached source location will override an installed jad-plugin.
If you're using maven and m2eclipse, you can simply right-click the lift-dep. -> Maven -> download sources. That will download the -sources.jar and automatically attach.
I man not sure you could get back the exact scala source, but at least you could try and see what the nsc bytecode looks like in Java.
This thread mentions (not tested myself) the Soot Eclipse plugin.
So I might settle on the Eclipse plugin for Soot, which can for example display bytecode using the Grimp notation (well, the following screenshot shows Jimple, but conveys the idea):

How to get Ant build errors inside Eclipse "Problems" view

When I set up an Ant script to run as an Ant builder in an Eclipse project, the only options I have for handling the output are to:
show it in Console view
capture it in a file
Is there any way to tell Eclipse how to parse the output and add entries to the Problems view accordingly?
I don't think you are going to find a solution, but if you do it would have to be a third-party plugin implementing a replacement Ant Builder. As you've discovered, Eclipse Ant build integration doesn't support this.
You may also want to consider opening an enhancement request at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform site. While there is no guarantee that someone will step up to implement this feature, you never can tell.

How to make a new Eclipse project template?

I am using a kind of framework where every time I make a new Java project. I have to arrange the files in the appropriate packages and reference the appropriate external JAR libraries. How do I make a new project template like in the New Project dialog under a new folder?
I've just done a bit of research on this for our own nefarious purposes, and found the answer.
You need to create an Eclipse plugin that uses the org.eclipse.ui.newWizards package. You can define your own category or use an existing one once you find the category ID. To create a new project wizard rather than a new resource wizard, you need to set the "project=true".
Also, your plugin must contain a class that implement org.eclipse.ui.INewWizard. Clicking on the class link from the plugin.xml editor will do the trick.
That class must do all the work in the performFinish override, and must return true to indicate that it actually did its thing and the wizard can close. This is where you create files, directories, set natures, and so forth.
You need to write an Eclipse plugin for that, and concentrate on New Project Wizard.
Writing Eclipse plugins is covered in Stack Overflow question How to write a plugin for Eclipse?.