Skip to content

Instantly share code, notes, and snippets.

Last active December 16, 2015 12:59
What would you like to do?
Full gradle setup to wrap a groovy script.
# 1. Install gvm
curl -s | bash
source "~/.gvm/bin/" # 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: ''" > 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>
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