Created
January 3, 2014 11:05
-
-
Save pcdv/8236256 to your computer and use it in GitHub Desktop.
This experimental script uses Gradle to build a classpath from a project's dependencies then run a given java class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Example: gradlerun path/to/ivyrepo com.example:mylib:+ com.example.MyMainClass arg1 | |
REPO=$1 | |
DEP=$2 | |
MAIN=$3 | |
ARG=$4 | |
shift 4 | |
SCRIPT=/tmp/gradlescript$$ | |
cat > $SCRIPT << EOF | |
apply plugin: 'java' | |
repositories { | |
mavenCentral() | |
ivy { | |
url "$REPO" | |
} | |
} | |
dependencies { | |
runtime "$DEP" | |
} | |
task(main, type: JavaExec) { | |
classpath = sourceSets.main.runtimeClasspath | |
main = "$MAIN" | |
args "$ARG" | |
} | |
EOF | |
trap "rm -f $SCRIPT" 0 | |
gradle -b $SCRIPT -q main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment