title: Replace class files before maven assembly
body: <p>I'm facing a very unique situation and need some advice:
  I'm working on a project which depends on an other project from my same company and now I need to apply some modifications to the dependency.
  The problem which I have is that the source code from the dependency has been lost, so the only thing I have is a maven dependency in the repository, with the corresponding jar file.
  On top of that, some of the classes in the Jar file where created using JiBX parser, mapping some XSD files which I neither have, and the resulting classes are synthetic and I found no decompiler able to handle them properly.</p>
  
  <p>The only good thing of all of that is that the class which I need to change can be properly decompiled, so went for the following:</p>
  
  <ul>
  <li>I decompiled the whole jar file and ended up with some classes (the
  JiBx ones) with empty or wrongly implemented methods.</li>
  <li>I commented out the body of the wrong methods to have stub objects, applied the required changes to the right classes and recompiled.</li>
  <li>I took the old Jar file, opened it and manually replaced the old class with the new one.</li>
  </ul>
  
  <p>And the resulting Jar worked as expected.</p>
  
  <p>Now my question is: Can I do all of that using Maven?</p>
  
  <p>The idea would be to put the JiBX class files as resources, and keep the stub equivalents as source files and then let maven:</p>
  
  <ul>
  <li>Compile everything as usual, putting all the compiled class files
  into target folder</li>
  <li>Remove stub class files from target folder and replace them with the old precompiled class files</li>
  <li>package the jar.</li>
  </ul>
  
  <p>Which approach would you recommend?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I give some more details about the dependency project structure:</p>
  
  <p>All classes are inside the same package:</p>
  
  <pre><code>my.project.domain.JiBX__c_GeneratedObfuscatedClass1.java
  my.project.domain.JiBX__c_GeneratedObfuscatedClass2.java
  my.project.domain.JiBX__c_GeneratedObfuscatedClass3.java
  my.project.domain.CustomizableClass1.java
  my.project.domain.CustomizableClass2.java
  my.project.domain.CustomizableClass3.java
  </code></pre>
  
  <p>JiBX classes are not imported properly as dependency and if I try to put any of the CustmizableClasses into the project source and let the JiBX ones be in a dependency, the compiler reports missing methods.</p>
  
  <p>I also tried using the Shade Plugin as suggested, but since I need to include the JiBX classes into my source path, I will end up having to include into package JiBX classes from jar dependency and compiled CustomizableClasses, but skipping CustomizableClasses from jar dep and compiled JiBX classes.</p>
  
  <p>I looks like it can work, but I admit that I still didn't find the way of doing it.
  Any clues will be very welcomed.</p>
  
  <p><strong>UPDATE 2 (RESOLUTION)</strong></p>
  
  <p>I explain here how I finally managed this using the shade plugin as suggested, just in case someone else needs to do the same:</p>
  
  <p>I finally created a project with the decompiled classes inside the same package, and left the methods which didn't want to be decompiled commented out.</p>
  
  <p>In the pom.xml I added the following:</p>
  
  <pre><code>&lt;build&gt;
  &lt;plugins&gt;
      &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.0&lt;/version&gt;
          &lt;executions&gt;
              &lt;execution&gt;
                  &lt;phase&gt;package&lt;/phase&gt;
                  &lt;goals&gt;
                      &lt;goal&gt;shade&lt;/goal&gt;
                  &lt;/goals&gt;
                  &lt;configuration&gt;
                      &lt;artifactSet&gt;
                          &lt;includes&gt;
                              &lt;include&gt;${project.groupId}:${project.artifactId}&lt;/include&gt;
                              &lt;include&gt;TheDamnedProject:WithoutSources&lt;/include&gt;
                          &lt;/includes&gt;
                      &lt;/artifactSet&gt;
                      &lt;filters&gt;
                          &lt;filter&gt;
                              &lt;artifact&gt;TheDamnedProject:WithoutSources&lt;/artifact&gt;
                              &lt;includes&gt;
                                  &lt;!-- These classes will be taken directly from dependency JAR --&gt;
                                  &lt;include&gt;my/package/ClassWhichCouldNotBeDecompiled1.class&lt;/include&gt;
                                  &lt;include&gt;my/package/ClassWhichCouldNotBeDecompiled2.class&lt;/include&gt;
                                  &lt;include&gt;my/package/ClassWhichCouldNotBeDecompiled3.class&lt;/include&gt;
                                  &lt;include&gt;my/package/ClassWhichCouldNotBeDecompiled4.class&lt;/include&gt;
                              &lt;/includes&gt;
                          &lt;/filter&gt;
                          &lt;filter&gt;
                              &lt;artifact&gt;${project.groupId}:${project.artifactId}&lt;/artifact&gt;
                              &lt;excludes&gt;
                                  &lt;!-- These classes will be overridden by the ones inside the JAR --&gt;
                                  &lt;exclude&gt;my/package/ClassWhichCouldNotBeDecompiled1.class&lt;/exclude&gt;
                                  &lt;exclude&gt;my/package/ClassWhichCouldNotBeDecompiled2.class&lt;/exclude&gt;
                                  &lt;exclude&gt;my/package/ClassWhichCouldNotBeDecompiled3.class&lt;/exclude&gt;
                                  &lt;exclude&gt;my/package/ClassWhichCouldNotBeDecompiled4.class&lt;/exclude&gt;
                              &lt;/excludes&gt;
                          &lt;/filter&gt;
                      &lt;/filters&gt;
                  &lt;/configuration&gt;
              &lt;/execution&gt;
          &lt;/executions&gt;
      &lt;/plugin&gt;
  &lt;/plugins&gt;
  </code></pre>
  
  <p></p>
  
  <p>thanks!</p>
  
  <p>Carles</p>