<!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;">
    Hacking AS7 using Eclipse
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="http://community.jboss.org/people/adietish">Andre Dietisheim</a> in <i>JBoss Tools</i> - <a href="http://community.jboss.org/docs/DOC-16718">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><h1>Preface</h1><p>There's already a article that shows you very well how to checkout and build the AS7 code base using command line tools. Unfortunately using Eclipse on top of those steps shows some gotchas that are not obvious. This article will show you how to import the AS7 projects to Eclipse.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1>Checkout the AS7 code base</h1><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The reference documentation may be reached at <a class="jive-link-wiki-small" href="http://community.jboss.org/docs/DOC-15596">http://community.jboss.org/wiki/HackingonAS7</a>. It shows you extensively what steps need to be achieve to get things up and running on the command line. Please follow these steps. I'll try to add the corresponding steps for <a class="jive-link-external-small" href="http://www.eclipse.org/egit/">EGit</a> later on</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><em>TODO: add instructions using EGit</em></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>Install M2Eclipse and EGit</h3><p>The next step involves installing the appropriate plug ins for Eclipse. The easiest way to achieve that is to install them from the Eclipse Marketplace.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/16140/install-from-marketplace.png"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/16140/install-from-marketplace.png </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/16139/install-egit.png"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/16139/install-egit.png </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 style="color: #333333; font-weight: bold; margin-left: 0pt; padding-top: 10px; padding-bottom: 4px; font-size: 18pt;"><a href="http://community.jboss.org/servlet/JiveServlet/showImage/16138/install-m2eclipse.png"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/16138/install-m2eclipse.png </span></a></h1><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1>Add local git Repository</h1><p><br/>After rebooting Eclipse, you'll now be able to import the local git repository.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-2-16132/add-local-git-repo.png"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-2-16132/449-73/add-local-git-repo.png </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-2-16133/add-local-git-repo-2.png"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-2-16133/450-455/add-local-git-repo-2.png </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1>Import Maven Project</h1><p>You'll then finally be able to import your AS7 sub-project into Eclilpse. Pick it in the list of available folders in the <strong>Working Directory</strong> and choose <strong>Import Maven Project</strong> from the context menu.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-2-16134/import-mavenproj-from-git.png"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-2-16134/439-593/import-mavenproj-from-git.png </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>You'll then end up with an project in your package explorer, that holds the name given to it in the maven pom.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1>Correct compilation errors</h1><h2>Run the maven build in eclipse</h2><p>You may eventually have to run the maven build in a first place so that all required maven artifacts get installed to the local maven repo. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>Quick fix the M2Eclipse lifecycle errors</h3><p>You may also experience maven related probles when using the latest <strong>m2eclipse 0.13</strong>. M2eclipse speeds up the build cycle by stripping it down to the bare minimum needed in Eclipse (you may read detailed documentation about in the <a class="jive-link-external-small" href="https://docs.sonatype.org/display/M2ECLIPSE/Project+build+lifecycle+mapping">m2eclipse wiki</a>). M2eclipse will therefore report you that specific plugins are not covered by the build lifecycle. Those errors are easily fixable with quick fixes that are offered to you in the pom editor.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2>Correct build path precedence errors</h2><p>You may experience compilation errors that are not related to m2eclipse. Most of them are due to the fact, that the build setup in Eclipse differs from what is used with bare Maven on the command line. </p><p>In my particular case, where I imported the AS7 demos, I ended up with the odd case where the Eclipse compiler complained about an illegal attribute to the <strong>@Resource</strong> annotation.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-2-16135/compilation-errors.png"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-2-16135/450-249/compilation-errors.png </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The compilation error that is reported is due to a bad resolution of the <strong>@Resource</strong> annotation. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If you use Eclipse with m2eclipse you'll end up with at least 2 <strong>compilation containers</strong> that resolve required classes. Eclipse will lookup in the <strong>JRE System Library</strong> in a first place and fall back to the <strong>Maven dependencies</strong> in a second step.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-2-16136/build-path.png"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-2-16136/450-121/build-path.png </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The Eclipse compiler actually applies the annotation that may be found in the <strong>jdk</strong>. This jdk annotation does not support the lookup attribute an the compilation therefore fails. On the other hand, the <strong>maven dependencies</strong> hold the correct, extended annotation which knows about a lookup attribute. So this boils down to the precendece of the compilation container in the Eclipse setup. You may fix the above error in the project build path:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Remove the <strong>JRE System Library</strong> and add it back again. The GUI will actually not show any change, it will still reflect the JRE System Library in first and the <strong>Maven Dependencies </strong>in second place. Behind the scenes though, their order was inverted. Eclipse now resolves artifacts from the Maven container first and will fall back to the JRE in a second step.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-2-16137/classpath-file.png"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-2-16137/450-90/classpath-file.png </span></a></p></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-16718">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>