title: How do I create an executable jar file including dependencies where the main class is in Test, using Maven
body: <p>I am new to Maven and have a project with the following directory structure</p>
  
  <pre><code>project
  
  -src
    -main
      -java
        -org
          -core
            -starter.java
    -test
      -java
        -org
          -core
            -testStarter.java
  </code></pre>
  
  <p>Both starter.java and testStarter.java are Main classes. However I wish to create an executable jar file (including dependencies) where testStarter.java is executed. </p>
  
  <p>I added the following to my pom file: </p>
  
  <pre><code>&lt;groupId&gt;org&lt;/groupId&gt;
  &lt;artifactId&gt;proj&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  &lt;name&gt;project&lt;/name&gt;
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;single&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;archive&gt;
                              &lt;manifest&gt;
                                  &lt;mainClass&gt;org.core.testStarter&lt;/mainClass&gt;
                              &lt;/manifest&gt;
                          &lt;/archive&gt;
                          &lt;descriptorRefs&gt;
                              &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                          &lt;/descriptorRefs&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>However everytime I run mvn clean package, it creates a package with only the compiled classes in the main directory and not the test directory. Hence everytime I run the jar file, it does not run, since the testStarter.class does not exist in the created jar file. </p>
  
  <p>Is there a way I can create either</p>
  
  <p>1) One big jar file containing test and main classes while it executes only the test class</p>
  
  <p>2) Only the test classes but all dependencies are included.</p>