Skip to content

Instantly share code, notes, and snippets.

@miku
Created June 5, 2013 08:07
Show Gist options
  • Save miku/5712337 to your computer and use it in GitHub Desktop.
Save miku/5712337 to your computer and use it in GitHub Desktop.
Fat shell script stub. Tags: Maven POM Executable Single JAR pom.xml build plugin ant
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.0</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.example.Main</Main-Class>
</manifestEntries>
</transformer>
</transformers>
<minimizeJar>false</minimizeJar>
<!-- when true: java.lang.ClassNotFoundException: org.hibernate.validator.HibernateValidator -->
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/>
<if>
<available file="${project.build.directory}/${project.build.finalName}.jar" type="file"/>
<then>
<delete file="${project.build.directory}/${project.artifactId}" failonerror="false"/>
<echo file="${project.build.directory}/${project.artifactId}">#!/bin/sh${line.separator}exec java -server -Xmx1024m -Xms1024m -jar $0 "$@"${line.separator}</echo>
<concat destfile="${project.build.directory}/${project.artifactId}" append="true" binary="true">
<filelist dir="${project.build.directory}" files="${project.build.finalName}.jar"/>
</concat>
<chmod file="${project.build.directory}/${project.artifactId}" perm="755"/>
</then>
<else>
<fail message="could not create superfat-script"/>
</else>
</if>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>20020829</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment