title: Different packaging with Spring Maven Plugin: Spring + Spark application
body: <p>I have a project which consists of three parts:</p>
  
  <ul>
  <li>Spring Boot application</li>
  <li>Spark Application</li>
  <li>"Library" used by both of the above (having this library as separate JAR or similar causes quiet a bit of overhead and slowed down the development)</li>
  </ul>
  
  <p>So what I want is a JAR that can be used to run the Spring Boot app (java -jar myapp.jar) as well as the Spark app (java -cp myapp.jar path.to.main.class).
  It is also OK to have two JARs - but both would need to be fat JARs (meaning: include dependencies).</p>
  
  <p>What I tried in the pom.xml is this:</p>
  
  <pre><code>  &lt;plugin&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
    &lt;/plugin&gt;
  </code></pre>
  
  <p>This creates (as expected) a fat JAR that can be used to run the Spring Boot app. But it cannot be used for the Spark app (as the classes and dependencies are somehow repackaged as I understand).</p>
  
  <p>My second try was this:</p>
  
  <pre><code>  &lt;plugin&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
      &lt;executions&gt;
        &lt;execution&gt;
          &lt;goals&gt;
            &lt;goal&gt;repackage&lt;/goal&gt;
          &lt;/goals&gt;
          &lt;configuration&gt;
            &lt;classifier&gt;exec&lt;/classifier&gt;
          &lt;/configuration&gt;
        &lt;/execution&gt;
      &lt;/executions&gt;
    &lt;/plugin&gt;
  </code></pre>
  
  <p>This creates the fat JAR as well plus another JAR just holding the classes that are implemented in my project - but without the dependencies. Therefore the Spark job does not start (as expected).</p>
  
  <p>Any idea how to solve this situation?</p>
  
  <p>Thanks!</p>