Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have a doubt about what you are trying to do but but I'll assume you want to reuse the tests that you have created for a project (module1) in another. As explained in the note at the bottom of the <a href="http://maven.apache.org/guides/mini/guide-attached-tests.html" rel="noreferrer">Guide to using attached tests</a>:</p> <blockquote> <p>Note that previous editions of this guide suggested to use <code>&lt;classifier&gt;tests&lt;/classifier&gt;</code> instead of <code>&lt;type&gt;test-jar&lt;/type&gt;</code>. While this currently works for some cases, it does not properly work during a reactor build of the test JAR module and any consumer if a lifecycle phase prior to install is invoked. In such a scenario, Maven will not resolve the test JAR from the output of the reactor build but from the local/remote repository. Apparently, the JAR from the repositories could be outdated or completely missing, causing a build failure (cf. <a href="http://jira.codehaus.org/browse/MNG-2045" rel="noreferrer">MNG-2045</a>).</p> </blockquote> <p>So, first, to package up compiled tests in a JAR and deploy them for general reuse, configure the <code>maven-jar-plugin</code> as follows:</p> <pre><code>&lt;project&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt; &lt;version&gt;2.2&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;goals&gt; &lt;goal&gt;test-jar&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>Then, install/deploy the test JAR artifact as usual (using <code>mvn install</code> or <code>mvn deploy</code>).</p> <p>Finally, to use the test JAR, you should specify a dependency with a specified type of <code>test-jar</code>:</p> <pre><code>&lt;project&gt; ... &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;com.myco.app&lt;/groupId&gt; &lt;artifactId&gt;foo&lt;/artifactId&gt; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt; &lt;type&gt;test-jar&lt;/type&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;/dependencies&gt; ... &lt;/project&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload