Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to run maven compile phase with test-jar dependencies
    primarykey
    data
    text
    <p>The project I'm working on is made of multiple modules, being built with maven. The test code in some modules has dependencies on test code from other modules. These dependencies are declared as below.</p> <p>In the dependency module:</p> <pre class="lang-xml prettyprint-override"><code>&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; </code></pre> <p>In the module which has the dependency on the previous module:</p> <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt; &lt;groupId&gt;${project.groupId}&lt;/groupId&gt; &lt;artifactId&gt;themodulename&lt;/artifactId&gt; &lt;version&gt;${project.version}&lt;/version&gt; &lt;type&gt;test-jar&lt;/type&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; </code></pre> <p>Using this configuration, the maven <em>install</em> phase can be executed successfully. But trying to run the <em>compile</em> or <em>test</em> phase fails, because the test jar file dependency cannot be resolved.</p> <p>Looking at the <em>test-jar</em> goal, it seems to be configured to run by default during the <em>package</em> phase, which I think is the cause of the problem.</p> <p>Then, I tried to force this goal to run during the <em>compile</em> phase, by modifying the first config into:</p> <pre class="lang-xml prettyprint-override"><code>&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;phase&gt;compile&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;test-jar&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>Looking at the debug logs, I can see that the goal is now executed during the <em>compile</em> phase, but also this:</p> <pre><code>[WARNING] JAR will be empty - no content was marked for inclusion! </code></pre> <p>I tried to configure the includes to **/* and confirmed that the default testClassesDirectory was set to the right one, but I still get the same warning.</p> <p>I could see that the test-classes folder didn't exist after running the <em>compile</em> phase, which seems normal, but even though it exists after running the <em>test</em> phase, and it contains files, I still get the "JAR will be empty" warning.</p> <p>Does anyone have any idea on fixing this configuration so that I can run successfully the <em>compile</em> or <em>test</em> phase?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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