title: Exclude test folder from maven build
body: <p>This is one of the most asked questions here in so... but why any answer works for me? i believe i have somehow a wrong maven structure in my project</p>
  
  <p>I have a project like</p>
  
  <pre><code>basedir
  |-src
  |--many many many packages
  |-test
  |--testpackages
  |-pom.xml
  </code></pre>
  
  <p>So my <code>pom.xml</code> is in the same level as <code>src</code> and <code>test</code> folders and it isn't the typical structure like java/main/ java/test... it is the root of the project folder</p>
  
  <pre><code>&lt;build&gt;
          &lt;sourceDirectory&gt;${basedir}/src&lt;/sourceDirectory&gt;
          &lt;testSourceDirectory&gt;${basedir}/test&lt;/testSourceDirectory&gt;
  
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-source-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.0.1&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;attach-sources&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;jar&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&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.5.1&lt;/version&gt;
  
                  &lt;configuration&gt;
                      &lt;source&gt;1.7&lt;/source&gt;
                      &lt;target&gt;1.7&lt;/target&gt;
                  &lt;excludes&gt;
                  &lt;exclude&gt;**/test/**&lt;/exclude&gt;
                  &lt;/excludes&gt;
                  &lt;/configuration&gt;
  
  
              &lt;/plugin&gt;
  
          &lt;/plugins&gt;
      &lt;/build&gt;
  </code></pre>
  
  <p>but when i run maven install and open the generated jar the folder test is in there...
  how can i solve and make it ignore this folder?</p>