Skip to content

Instantly share code, notes, and snippets.

@gabehamilton
Last active December 16, 2015 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabehamilton/5438907 to your computer and use it in GitHub Desktop.
Save gabehamilton/5438907 to your computer and use it in GitHub Desktop.
Full gradle setup to wrap a groovy script.
# 1. Install gvm
curl -s get.gvmtool.net | bash
source "~/.gvm/bin/gvm-init.sh" # will vary depending on your Operating System, read the output of gvm for the exact command
# 2. Install gradle
gvm install gradle
# 3. Grab a gradle project template
echo "apply from: 'http://www.tellurianring.com/projects/gradle-plugins/gradle-templates/apply.groovy'" > build.gradle
# and use it to create a new project
#This asks for a project name and some details and creates a directory with the same name as the project.
gradle createGroovyProject
# 4. Put the script that you are wrapping (SomeScript.groovy) below the <project_name>/src/main/groovy directory.
# 5. Grab gradle code for building the script into a jar file
cd <project_name>
wget https://gist.github.com/scottfrederick/2172836/raw/13bcadfee73c615905dad0eba6cb5c899ad7a2f6/build.gradle
mv build.gradle.1 build.gradle
# 6. set the main class name in build.gradle
# comment out or remove the example jars
# optionally add your organization for publishing: group = 'com.example'
# 7. Build it
gradle build
# 8. Test it out
java -jar build/libs/<project_name>-1.0.jar
# 9. Bonus points, Grab the gradlew executable so that other people don't need gvm or gradle.
echo "task wrapper(type: Wrapper) { gradleVersion = '1.5'}" >> build.gradle
gradle wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment