How to create an Eclipse plugin for custom Ant tasks? - eclipse

I have written a couple of Ant tasks in Eclipse that may be of use to more people, and am looking for a way to make them easily distributable. Creating an Eclipse plugin that provides these Ant tasks is the first thing that came to mind, but I'm not quite sure how to do this.
Are there any good tutorials out there on how to create an Eclipse plugin that provides only a couple of Ant targets?

Related

Scripting the setup of Eclipse

I'm currently messing around with scripting the setup of Eclipse using ant. The idea is to create a one-button setup of our development environment, replacing an existing Word document which describes how to do so manually.
The setup involves things like unzipping Tomcat servers, unzipping a virgin Eclipse instance, installing plugins on top of Eclipse, etc. All of this is working smoothly now.
Another part of the setup involves configuring things in Eclipse -- the things that you would normally do using the Eclipse UI. This involves things like picking a specific JRE, creating a server in Eclipse, creating a workspace, importing some projects into the workspace.
I've had some modest successes in initializing the Eclipse preferences by simply writing files into the preference folders of Eclipse. But this is based upon reverse engineering and feels like a fragile approach. Furthermore, I have not yet worked out how to import the existing projects.
Am I overlooking the easy and robust way to achieve this?
I have done similar thing previously and I have found the reverse engineering approach to work well for preferences.
The only way I have found to import existing projects is to write a headless Eclipse plugin that uses IWorkspace, IProjectDescription and IProject. Check this thread on Eclipse Community Forums for some pointers. You can also find more information about it in the Eclipse help.
Then it's just a matter of executing Eclipse from your script with some parameters like
-nosplash -application [your plugin] -data [workspace folder]

In Eclipse for Java -JDT (DynWeb), Is Eclipse using default ant build.xml ? behind the scenes?

I believe when Eclipse installs, ant comes with it.
I should review the default build.xml
( I assume it uses one, whether or not it is obviously included in the project files )
I need to find out where it would store and use this from.
I have some projects / code artifacts that come with a build spec, and may need to use the one specified. Thanks in advance for your help, and suggestions.
Eclipse doesn't use ant to build your projects, if that's what you are asking. Eclipse builders (such as Java builder) are implemented natively as Eclipse plugins. Eclipse does support integration with Ant... Calling ant targets as part of the build... Calling ant targets as separate tools... Ant is meant to be used to augment IDE-provided facilities when you need something specialized.

Continuous integration & eclipse plugin development

I am developing a set of eclipse plugins, and I have several JUnit plugin tests that actually start another instance of eclipse, create a mock workspace and a mock project and runs various operations on them. I want to put that on continuous integration and I am at loss as to where to start. I am using Hudson, would there be any plugins that makes that easier? Can those tests launch eclipse in headless mode or something on the CI server? Pointers would be much appreciated.
I think the best solution for building Eclipse-based software currently is Tycho - it is based on Maven and uses your standard Eclipse files (like manifest, target platform, product definition). I got started with it using an intro from this blog: http://mattiasholmqvist.se/2010/02/building-with-tycho-part-1-osgi-bundles/, and it worked really well. We also use Hudson, and since Tycho is Maven-based, Hudson integration was trivial and worked simply by calling Maven, which Hudson supports out of the box.
As far as I know, Buckminster tries to solve these problems: you can create descriptors, and then Buckminster can execute your tasks.
For Hudson there is a Buckminster module, that helps executing the Buckminster builds.
maybe this helps you to avoid plugin tests? ;) i like to avoid them... by using mock objects...
http://blog.srvme.de/2010/12/10/mock-eclipse-ifile/

Make Custom Project template in Eclipse IDE

I have been using Eclipse IDE for a long time. Its a really great IDE for Java/C/C++ (and other languages with its THOUSANDS of plugins). Every once in a while, I get the need for creating a Javax interface. To do this normally, I would setup the new java project then add what I need. But, wouldn't it be nice if I could just make a template project to automatically include the code for the files. How would I go about doing this? It it even possible? The Eclipse CDT can make a new project type. So can the Google ADT and Google App engine. So I would imagine it is possible. But how?
You must write your Eclipse plug-in that implements org.eclipse.ui.newWizards extension point. You can extend an existing "New Java Project" wizard, and provide your custom project layout implementation (see the API).
Regarding java projects you might be familiar with maven. Maven offers of project template mechanism called archetypes. I never created an own archetype but the explanation to do this (Guide to Creating Archetypes) does not seems to be so complicated.
So although this is not a special eclipse solution it might be helpful for you. Together with the m2eclipse plugin it also works nice together with eclipse.

Publish WTP project in Eclipse from Ant

Is there any way to have an Ant script running in Eclipse publish a WTP project? I want my ant script to perform some tasks, then kick off the publish as if I had done it from the UI, and then do some more things.
Don't know how far you got with this. But if you create your own ant script, and put
at the top, your script will get imported in the the WTP generated ant script. That said, all i've gotten it to do is add the targets, I haven't quite figured out the "hooking in" to existing behaviour yet.
If you did find anything interesting, post it, as I'm looking for more info on integrating WTP with existing builds.