Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble getting started with maven assembly plugin
    text
    copied!<p>I'm sorry to sound ignorant here, but I'm new to Maven, and have been banging my head against something that I'm sure is quite simple.</p> <p>The <a href="http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_assembly" rel="noreferrer">docs</a> say: </p> <blockquote> <p>[...] a project could produce a ZIP assembly which contains a project's JAR artifact in the root directory, the runtime dependencies in a lib/ directory, and a shell script to launch a stand-alone application.</p> </blockquote> <p>which is <strong>exactly</strong> what I want to do! But I can't seem to make it happen.</p> <p>My POM is as follows:</p> <pre><code>&lt;project&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;com.anearalone&lt;/groupId&gt; &lt;artifactId&gt;myapp&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;jar&lt;/packaging&gt; [...] &lt;build&gt; &lt;finalName&gt;myapp&lt;/finalName&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt; &lt;version&gt;2.2.1&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;make-assembly&lt;/id&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;descriptors&gt; &lt;descriptor&gt;src/main/assemble/dist.xml&lt;/descriptor&gt; &lt;/descriptors&gt; &lt;archive&gt; &lt;manifest&gt; &lt;mainClass&gt;com.anearalone.myapp.CLI&lt;/mainClass&gt; &lt;addClasspath&gt;true&lt;/addClasspath&gt; &lt;classpathPrefix&gt;lib/&lt;/classpathPrefix&gt; &lt;/manifest&gt; &lt;/archive&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; [...] &lt;/project&gt; </code></pre> <p>and the referenced dist.xml looks like this:</p> <pre><code>&lt;assembly&gt; &lt;id&gt;dist&lt;/id&gt; &lt;formats&gt; &lt;format&gt;zip&lt;/format&gt; &lt;/formats&gt; &lt;files&gt; &lt;file&gt; &lt;outputDirectory&gt;/&lt;/outputDirectory&gt; &lt;source&gt;src/main/bin/arkify.sh&lt;/source&gt; &lt;fileMode&gt;755&lt;/fileMode&gt; &lt;/file&gt; &lt;/files&gt; &lt;dependencySets&gt; &lt;dependencySet&gt; &lt;useProjectArtifact&gt;false&lt;/useProjectArtifact&gt; &lt;includes&gt; &lt;include&gt;*:jar&lt;/include&gt; &lt;/includes&gt; &lt;outputDirectory&gt;/lib&lt;/outputDirectory&gt; &lt;/dependencySet&gt; &lt;dependencySet&gt; &lt;useProjectArtifact&gt;true&lt;/useProjectArtifact&gt; &lt;includes&gt; &lt;include&gt;com.anearalone:myapp:jar:0.0.1-SNAPSHOT&lt;/include&gt; &lt;/includes&gt; &lt;outputDirectory&gt;/&lt;/outputDirectory&gt; &lt;/dependencySet&gt; &lt;/dependencySets&gt; &lt;/assembly&gt; </code></pre> <p>This achieves the layout I want in the zip file (though I'm quite sure I'm not getting there in the correct way) but I get two jars in <code>target/</code> (one in the zip archive, the other in the root), and neither of them includes my mainClass entry in the resultant <code>MANIFEST.MF</code>.</p> <p>If I change the <code>project.packaging</code> to "pom", which I thought might be correct, of course the extra jar (in the root of <code>target/</code> goes away, but I get these warning:</p> <pre><code>[WARNING] Cannot include project artifact: com.anearalone:myapp:pom:0.0.1-SNAPSHOT; it doesn't have an associated file or directory. [WARNING] The following patterns were never triggered in this artifact inclusion filter: o 'com.anearalone:myapp' </code></pre> <p>... and indeed my artifact is not in the archive, and there are still no entries added to <code>MANIFEST.MF</code>.</p> <p>Anyone have time to help out a beginner?</p>
 

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