<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    How to use the Python ant-to-Eclipse example converter scripts
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="http://community.jboss.org/people/admin">Administrator Administrator</a> in <i>JBoss Tools</i> - <a href="http://community.jboss.org/docs/DOC-16175">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><div class="ennote"><h2>Overview</h2><div>Though it still doesn't have a great name, I've put together a set&#160; of Python scripts that will take an ANTified runtime example, such as&#160; one of the ESB examples, and convert it into an import-ready Eclipse&#160; project.</div><div><br clear="none"/></div><div>Why do we need this you may ask? Well, we have a subset of examples&#160; in the Project Examples functionality provided with JBoss Tools and&#160; JBoss Developer Studio. But it's just a subset. There are many more&#160; example projects provided with runtimes such as EAP and SOA-P that&#160; aren't there. Rather than have the same example represented in two&#160; different places, which has potential issues with keeping them in sync,&#160; we can simply take the original runtime example and transform it&#160; (one-way only) into a form that Eclipse recognizes.</div><div><br clear="none"/></div><div>The scripts aren't perfect. But it's a start.</div><div><br clear="none"/></div><h2>Where to find them...</h2><div>For now, I've put the script into a workspace directory in the JBoss Tools SVN repository:</div><div><br clear="none"/></div><div style="padding-left: 30px;"><a class="jive-link-external-small" href="http://https://anonsvn.jboss.org/repos/jbosstools/workspace/bfitzpat/org.jboss.tools.py.project.converter">https://anonsvn.jboss.org/repos/jbosstools/workspace/bfitzpat/org.jboss.tools.py.project.converter</a></div><div><br clear="none"/></div><div>The project was created using the PyDev plug-ins for Eclipse, so if&#160; you have that installed you can load them into Eclipse. But you can&#160; also run them from the command line like any other Python script.</div><div><br clear="none"/></div><div>Once you've checked out the project, drill into it and find the src directory. There you'll find all the scripts.</div><div><br clear="none"/></div><div>You will need to customize <strong>constants.py</strong> file to match your&#160; environment and the <strong>Main.py</strong> file to point to the examples you want to&#160; convert, but once you've done that just type the following at the&#160; command line:</div><div><br clear="none"/></div><div style="padding-left: 30px;">&gt;python Main.py</div><div><br clear="none"/></div><div>You will see something like the following if the script is correctly configured for your runtime:</div><div><a href="http://community.jboss.org/servlet/JiveServlet/showImage/102-16175-1-10681/converter_py_terminal.jpg"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16175-1-10681/450-256/converter_py_terminal.jpg </span></a></div><h2>How to Customize the scripts...</h2><div>To make the script work, you'll need to have a server runtime&#160; instance in the Servers view already created. The converted project&#160; requires the name of that server for various settings in project&#160; configuration files.</div><div><br clear="none"/></div><div>In the <strong>constants.py</strong> file, you'll find one constant you'll need to&#160; change - runtimeTargetServerName. Change the quoted name to the name of&#160; your server and save the file.</div><div><br clear="none"/></div><div>&#160;&#160;&#160; runtimeTargetServerName = 'My Server'<br clear="none"/></div><div><br clear="none"/></div><div>Now to tell the script which examples to convert, you can update the <strong>Main.py</strong> file. I've set up a "localruntime" variable for the path of the examples&#160; directory in your runtime. And then all you have to do is add the&#160; directory names for the examples to convert.</div><div><br clear="none"/></div><div>So if your local runtime samples directory is at&#160; /usr/home/runtime/samples and you want to convert "MyExample", the code&#160; would look something like this:</div><div><br clear="none"/></div><div>&#160;&#160;&#160;&#160; # change this list to be appropriate to your own runtime directory and<br clear="none"/>&#160;&#160;&#160;&#160; # list of projects to convert <br clear="none"/>&#160;&#160;&#160;&#160; localruntime = '/usr/home/runtime/samples'<br clear="none"/>&#160;&#160;&#160;&#160; <br clear="none"/>&#160;&#160;&#160;&#160; toconvert.append('MyExample')</div><div><br clear="none"/></div><div>You can add as many examples as you want. But be aware that it&#160; creates a parallel example in the same directory for each Eclipse&#160; project. So "MyExample" becomes "MyExample_eclipse" in the same samples&#160; directory. And it will delete the new example project directory if it&#160; already exists, so make sure you back it up first if you want to keep&#160; it.</div><div><br clear="none"/></div><h2>Additional Customizations...</h2><div>I have tested the script on several ESB examples that are shipped&#160; with the SOA-P runtime. The list includes: deadletter,&#160; helloworld_file_action, helloworld_file_notifier, and&#160; helloworld_ftp_action (among with a few others). These are basic&#160; examples that don't include additional runtimes such as Drools. So there&#160; is still work to be done here.</div><div><br clear="none"/></div><div>If you look into the <strong>file_handler.py</strong> script, you can see multiple&#160; methods for dealing with the creation or copying of specific files. The&#160; <strong>dir_handler.py</strong> script handles various directories. And methods in both&#160; are called by <strong>converter.py</strong>, which is the main class used to convert the&#160; projects.</div><div><br clear="none"/></div><div>You can add your own files and directories and customizations (for&#160; Drools or other requirements) as necessary. And we will eventually build&#160; out these scripts to handle as many of the available runtime examples&#160; as possible.</div><div> </div><h2>Once the conversion is done...</h2><p>Once the <strong>Main.py</strong> script is run and your examples are converted, you can import them in Eclipse using the File-&gt;Import-&gt;Existing Projects into Workspace menu.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2>Finally...</h2><p>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.</p><div><br clear="none"/></div></div></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-16175">going to Community</a></p>

        <p style="margin: 0;">Create a new document in JBoss Tools at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2128">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>