Find file
d1bd1b9 Jan 22, 2017
62 lines (52 sloc) 2.04 KB
@description "teaches a maven project how to make an executablejar"
@tag "maven"
editor MakeExecutableJar
@displayName "Main Class"
@description "Fully qualified Java classname"
@minLength 1
@maxLength 100
param main_class: @java_package
let pluginContents = """<plugin>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
let runScript = """#!/bin/bash
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
java -jar $DIR/../target/executable.jar "$@"
with Pom p
do addOrReplaceBuildPlugin "org.apache.maven.plugins" "maven-shade-plugin" pluginContents
with File f when path = "pom.xml" begin
do replace "__I_AM_THE_MAIN__" main_class
do eval { print("run `mvn package` to create an executable jar")}
with Project p begin
do eval { print("Find a run script in your project's bin directory. You'll have to make it executable yourself, sorry") }
do addFile "bin/run" runScript