Hook into the Eclipse build process? - java

I'd like to be able to run a simple Java program when the build button is pressed in Eclipse. Currently when I click build, it runs some JRebel logging code. I have a program that parses the JRebel log file and stores statistics in a DB.
Is it possible to write a plugin or somehow hook into the build process of Eclipse, so that after the JRebel logging is done, it will run my program to parse the file automatically?
Any help would be appreciated, even if you could just point me in the right direction.
Thanks in advance.

You can add a custom Builder to your java project.
Right-click on your project. Select Properties.
In the tree on the left side choose 'Builders'.
You can either add an ant script or specific program. You also have ability to choose when this tool will be running ( before or after Java Builder ).

You can write an incremental project builder and register it via extension point: http://www.eclipse.org/articles/Article-Builders/builders.html

Related

How to take chages from my IDE Eclipse to the run time execution for my plug-in

Please I am using plug-in development tool in Eclipse. I run my plug-in like that: Run=> Run as=> Eclipse application another ide for execution opend and I see result, but when i change the code in my IDE of plug-in development I need to close the execution application and run again to see the new result.
I want to modify in the IDE and keep see the new changes in the runtime-EclipseApplication there is way please to that ? thanks .
Debug=> Debug as=> Eclipse application will cause code changes to be swapped into the runtime VM as you make them, assuming Automatic building is enabled, just as it does for any other Java application. However, it will not make changes in your plug-in MANIFEST.MF or plugin.xml take effect--that still requires restarting and clearing the Configuration space.

Eclipse: auto execute and generate code on save

I'm using Eclipse and I wanted to create a system that automatically generates java source code every time I save the project. More precisely I want to search for some files in a directory, generate static attributes for each of them and generate some methods every time the project is updated/saved. I thought that a piece of code that could be auto-executed by Eclipse would be fine, but I don't know if it's even possible. How can I achieve this behaviour?
You can specify a program or Ant script to be run when a project needs building in the 'Builders' section of the Properties for a Project.
You can also write an Eclipse plugin 'Incremental Builder' using the 'org.eclipse.core.resources.builders' extension point. More information about this in the Eclipse help.
Eclipse has an extension point for cleanup and save actions that will be executed when you a save a file.
This requires implementing and installing a custom Eclipse plugin, so it's more intrusive than using a builder to run a script, but also more flexible, since you can use the JDT API to inspect the Java model of the given file.
I personally use :https://github.com/mystilleef/eclipse4-smartsave
Just from marketplace eclipse4-smartsave or as on page other solutions.
Plugin sometimes hangs, still it is great.

Eclipse plugin not working properly

I developed an Eclipse plugin that compiles and runs java code in German. The technique I am using is that I translate the code to English and pass it to Java Compiler and get the results back and print it in the console.
The problem is that the plugin works when I run the plugin from Inside Eclipse but when I install the plugin in Eclipse so that when I open Eclipse it already exists there and start to test if a real user uses my plugin and creates a new Java project and try to the compile button in my plugin it says [The chosen operation is not currently available] ![Here is the the way I run and it opens a new Eclipse application with the installed plugin ]
Any help please
the way you installed your plugin sounds a little weird to me. So at first please try to export your plugin via the Export Wizard.
(Select Export -> Deployable plugins and features from your projects context menu)
Export your project as jar file and copy it to the 'plugin' folder of your eclipse instance.
After that it might be helpful to debug your plugin on OSGI-Level as there might be a problem loading your plugin (at least the error description you have posted indicates that).
Run eclipse with -console -noExit -consoleLog flags to open an OSGI console for debugging. After that try running ss <your-plugin-name> to see what the state of your plugin is.
The output gives you the ID of your plugin and the state it currently has. If the state of your plugin is not ACTIVE try running start <your-plugin-id> to see whether it starts correctly. If there is a problem starting your plugin you should get a respective log message. Feel free to post it here in case you need further help.
Otherwise there are plenty of options what might cause your problems, so maybe its better to try the steps I have described above before getting into details.
If you want to run eclipse plug-in withput using Eclipse Application , then you need to make a Feature project.
Now if your algorithm has something to do with system Path , you must
check Unpack plug-in and you should read the resource accordingly.
Like PLatformUI.getWorkBC() etc..
No other eclipse plug-in (jar) should be inside plugins directory of eclipse of same name of your plug-in. Ensure for this.

Unable to run Java program in Eclipse Juno 4.2

I reinstall my Eclipse environment every year when the new version is released. The most recent release - Juno - however, does not work as expected.
Currently, when I try running demos from Oracle, for example, it asks me to select an Ant file to run before compiling. After creating a blank Ant file to bypass the requirement (which I thought was rather dumb, since I don't think TDD is something that should be forced on people), it still refused to run, saying the "Selection could not be launched."
I understand that Juno is an update from the 3.x track to the 4.x track, but this seems a little ridiculous to me. What can or should I do so I can get Eclipse back up and running again?
Just to clarify:
All files in question are on my Eclipse workspace path
I don't do much in the way of Java development, though I know I'll need to do so soon. Hence, my unfamiliarity with the most recent version of Eclipse.
I would like to run my files & projects without Ant files. I know it has something to do with Run configs, but I don't know how to change them.
Here's what I did to run the demo from Eclipse Juno:
Downloaded the project from http://docs.oracle.com/javase/tutorial/uiswing/examples/zipfiles/components-FrameDemoProject.zip (if this is not the correct demo, then please provide the link you're using)
Unzipped it to my projects directory (not my workspace), so that you have:
PROJECTS_DIR/components-FrameDemoProject/src
PROJECTS_DIR/components-FrameDemoProject/nbproject
PROJECTS_DIR/components-FrameDemoProject/build.xml
From Eclipse, File > New > Java Project
List item Uncheck Use default location and navigate to <PROJECTS_DIR>/components-FrameDemoProject
Hit Finish
Drill down to src/components/FrameDemo.java
Right-click on FrameDemo.java and select Run As > Java Application
Let me know if any of these steps give you trouble.
Take a look at you project properties and select the Builders entry. Do you see an Ant Builder entry? Try to select or create a Java Builder entry instead.
I just created a new Java Project in Juno and added the FrameDemo.java source. In my case, the Java Builder was selected as the default for this new project.

Configure Eclipse to launch a fixed project in a workspace?

I have a small workspace with 3 projects. One main (Swing) application, two other projects that are just libraries.
Now, whenever I change stuff in my library project and want to execute i.e. run with Ctrl+F11) or debug , I have to select my main project first and run that.
Is there any way to set this up more smoothly, so I can just run my program regardless of which of my 3 project that is selected ?
Have a look at the "Launching" preference page. At the botton you can select *Always launch the previously launched application. That should do the trick...
If you are using Maven you can create hierarchical structure of projects, i.e. head and child projects. In this case try to define Run/Debug profile on the parent's project level. Probably it will work from any other child project.
I personally have never try this and unfortunately cannot try this right now but I hope it will work for you.
If it does not work it seem you have to create your own eclipse plugin.
Good luck.

Categories