[jboss-user] [JBoss Tools] - How to use the Python ant-to-Eclipse example converter scripts
do-not-reply at jboss.com
Mon Jan 24 09:31:22 EST 2011
Administrator Administrator [http://community.jboss.org/people/admin] modified the document:
"How to use the Python ant-to-Eclipse example converter scripts"
To view the document, visit: http://community.jboss.org/docs/DOC-16175
Though it still doesn't have a great name, I've put together a set of Python scripts that will take an ANTified runtime example, such as one of the ESB examples, and convert it into an import-ready Eclipse project.
Why do we need this you may ask? Well, we have a subset of examples in the Project Examples functionality provided with JBoss Tools and JBoss Developer Studio. But it's just a subset. There are many more example projects provided with runtimes such as EAP and SOA-P that aren't there. Rather than have the same example represented in two different places, which has potential issues with keeping them in sync, we can simply take the original runtime example and transform it (one-way only) into a form that Eclipse recognizes.
The scripts aren't perfect. But it's a start.
h2. Where to find them...
For now, I've put the script into a workspace directory in the JBoss Tools SVN repository:
The project was created using the PyDev plug-ins for Eclipse, so if you have that installed you can load them into Eclipse. But you can also run them from the command line like any other Python script.
Once you've checked out the project, drill into it and find the src directory. There you'll find all the scripts.
You will need to customize *constants.py* file to match your environment and the *Main.py* file to point to the examples you want to convert, but once you've done that just type the following at the command line:
You will see something like the following if the script is correctly configured for your runtime:
h2. How to Customize the scripts...
To make the script work, you'll need to have a server runtime instance in the Servers view already created. The converted project requires the name of that server for various settings in project configuration files.
In the *constants.py* file, you'll find one constant you'll need to change - runtimeTargetServerName. Change the quoted name to the name of your server and save the file.
runtimeTargetServerName = 'My Server'
Now to tell the script which examples to convert, you can update the *Main.py* file. I've set up a "localruntime" variable for the path of the examples directory in your runtime. And then all you have to do is add the directory names for the examples to convert.
So if your local runtime samples directory is at /usr/home/runtime/samples and you want to convert "MyExample", the code would look something like this:
# change this list to be appropriate to your own runtime directory and
# list of projects to convert
localruntime = '/usr/home/runtime/samples'
You can add as many examples as you want. But be aware that it creates a parallel example in the same directory for each Eclipse project. So "MyExample" becomes "MyExample_eclipse" in the same samples directory. And it will delete the new example project directory if it already exists, so make sure you back it up first if you want to keep it.
h2. Additional Customizations...
I have tested the script on several ESB examples that are shipped with the SOA-P runtime. The list includes: deadletter, helloworld_file_action, helloworld_file_notifier, and helloworld_ftp_action (among with a few others). These are basic examples that don't include additional runtimes such as Drools. So there is still work to be done here.
If you look into the *file_handler.py* script, you can see multiple methods for dealing with the creation or copying of specific files. The *dir_handler.py* script handles various directories. And methods in both are called by *converter.py*, which is the main class used to convert the projects.
You can add your own files and directories and customizations (for Drools or other requirements) as necessary. And we will eventually build out these scripts to handle as many of the available runtime examples as possible.
h2. Once the conversion is done...
Once the *Main.py* script is run and your examples are converted, you can import them in Eclipse using the File->Import->Existing Projects into Workspace menu.
The goal of these scripts is not to be an ultimate solution, but to provide a more automated way of bringing existing runtime examples into the Eclipse tooling. Hopefully they will mature over time, but in the meantime provide some basic functionality to help out users both new and old start to explore more JBoss functionality via the tooling.
Comment by going to Community
Create a new document in JBoss Tools at Community
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jboss-user