CopyPastor

Detecting plagiarism made easy.

Score: 0.8142914772033691; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2022-11-30
by Ondra Žižka

Original Post

Original - Posted on 2009-02-26
by Matthew McCullough



            
Present in both answers; Present only in the new answer; Present only in the old answer;

For those hitting this page from a search engine:
The `appassembler-maven-plugin` is abandoned since 2015.
Please use the `maven-assembly-plugin`.
Below are 2 examples - with an explicit descriptor file, and one relying on a pre-defined descriptor.
<!-- The executable JAR(s) --> <plugin> <groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>3.4.2</version> <executions> <execution> <id>assembleDistZip</id><goals><goal>single</goal></goals><phase>package</phase> <configuration> <finalName>${project.artifactId}-${project.version}-dist</finalName> <archive> <manifest> <mainClass>${mainClass}</mainClass> <addClasspath>false</addClasspath> <classpathPrefix>lib/</classpathPrefix> </manifest> </archive> <descriptors><descriptor>src/build/assembly-dist.xml</descriptor></descriptors> </configuration> </execution>
<execution><phase>package</phase><goals><goal>single</goal></goals> <configuration> <appendAssemblyId>false</appendAssemblyId> <finalName>${project.artifactId}</finalName> <outputDirectory>${project.build.directory}/dist</outputDirectory> <descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs> <archive> <manifest> <!-- Jar - MANIFEST.MF options. --> <addClasspath>false</addClasspath> <mainClass>${mainClass}</mainClass> <classpathPrefix>lib/</classpathPrefix> </manifest> <manifestEntries> <Release-Version>${project.version}</Release-Version> </manifestEntries> </archive> </configuration> </execution> </executions> </plugin>
Taking [IAdapter's answer][1] and reformatting it, we have:
<!-- language: xml -->
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>fully.qualified.MainClass</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build>
Next, I would recommend making this a natural part of your build, rather than something to call explicitly. To make this a integral part of your build, add this plugin to your `pom.xml` and bind it to the `package` lifecycle event. However, a gotcha is that you need to call the `assembly:single` goal if putting this in your pom.xml, while you would call 'assembly:assembly' if executing it manually from the command line.
<!-- language: xml -->
<project> [...] <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>fully.qualified.MainClass</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-my-jar-with-dependencies</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> [...] </plugins> [...] </build> </project>
[1]: https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven/574650#574650








        
Present in both answers; Present only in the new answer; Present only in the old answer;