title: Deploy Maven artifacts to <container>/shared/lib for Eclipse debugging?
body: <p>I'm working with some very old, monolithic software that is basically a heavily customized JBoss deployment.  Unfortunately, this means that JBoss can't be started from the "Servers" view in Eclipse, it must be started as a Windows service or via the command line.  There are multiple WARs/EARs, but the WAR classloaders are rarely used and most of the actual class files are located in jboss/shared/lib as .jars.  </p>
  
  <p>We need a way to run a Maven build in Eclipse (via m2e) and deploy the class files in the resulting .jar to C:/product/jboss/shared/lib so that when we start JBoss, we can use Eclipse to debug (as a remote java application).  Ideally, the artifact that Maven pushes will not overwrite the existing .jar file that was originally installed.  For example, if  the Maven project builds an artifact named myjar-1.0.0.jar, we need a way to deploy the classes inside of myjar-1.0.0.jar to C:/product/jboss/shared/lib/classes so that they are picked up by the classloader prior to C:/product/jboss/shared/lib/myjar-1.0.0.jar, which was installed with the product.</p>
  
  <p>Currently, our (<em>very</em> hacky) solution is this:</p>
  
  <ol>
  <li><p>Under the project configuration's <code>Java Build Path</code> > <code>Source</code> tab, we use the "symlink" functionality under <code>Advanced</code> to map the <code>Default Output Directory</code> (e.g. project/target/classes) to a class folder (e.g. C:/product/jboss/shared/lib/classFolder).  This modifies the .project file, which is checked into source control.</p>
  
  <p><img src="https://i.stack.imgur.com/Bz9bR.png" alt="symlink madness"></p></li>
  <li>We build the project normally with a m2e launcher (e.g. clean install).</li>
  <li><p>Assuming the Maven build is successful, we run an Eclipse project build.  This pushes the class files to C:/product/jboss/shared/lib/classFolder:</p>
  
  <p><img src="https://i.stack.imgur.com/kYoys.png" alt="classFolder"></p></li>
  <li>We restart JBoss.  Since classFolders take precedence over jars, JBoss will load the classes in C:/product/jboss/shared/lib/classFolder, which are identical to the classes in our Eclipse workspace.</li>
  <li>We attach to JBoss and debug the project as a remote java application.</li>
  </ol>
  
  <hr>
  
  <p>Pros:</p>
  
  <ul>
  <li>We're able to push our new classes to JBoss and test them without backing up the original jars and copy/pasting the new ones by hand (jar hell).</li>
  </ul>
  
  <p>Cons:</p>
  
  <ul>
  <li>We're compiling twice -- once with the maven-compiler-plugin, and
  once with an Eclipse project build (Java Builder). </li>
  <li>The symlink functionality is hit or miss in my experience.  Sometimes we need to
  do the refresh project/close project/build project dance to get it to
  work.</li>
  </ul>
  
  <p><strong>Is there a better way to do this?</strong>  I cannot force them to restructure the project so heavily that all deployables are container-agnostic WARs, but our developers need to be able to make changes and quickly test them without manually copy/pasting .jars.</p>