Skip to content

Instantly share code, notes, and snippets.

@msimonin
Last active August 29, 2015 14:03
Show Gist options
  • Save msimonin/413c6172a0911799b18f to your computer and use it in GitHub Desktop.
Save msimonin/413c6172a0911799b18f to your computer and use it in GitHub Desktop.
example of maven assembly plugin (issue with sshj and shaded jars)
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>mon-dir-final</id>
<formats>
<format>dir</format>
</formats>
<fileSets>
<fileSet>
<directory>target</directory>
<outputDirectory>.</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
</dependencySet>
</dependencySets>
</assembly>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.inria</groupId>
<artifactId>testsshj</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<id>sonatype</id>
<url>http://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>testsshj.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>assemble/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.schmizz</groupId>
<artifactId>sshj</artifactId>
<version>0.9.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
@msimonin
Copy link
Author

msimonin commented Jul 3, 2014

copy/paste the pom.xml and assemble/assembly.xml

mvn package

from target/testsshj-0.0.1-SNAPSHOT-mon-dir-final/testsshj-0.0.1-SNAPSHOT

run java -jar testsshj-0.0.1-SNAPSHOT.jar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment