groovy - How to make a task to call a main class -
what trying make task in build.gradle execute main class (class main method), don't know how.
i made test project test how that. here file structure layout:
testproject/ build.gradle src/main/groovy/hello/world/helloworld.groovy
here content of build.gradle:
apply plugin: 'groovy' apply plugin: 'maven' repositories { mavencentral() } dependencies { compile 'org.codehaus.groovy:groovy-all:2.0.6' } task( hello, dependson: jar, type: javaexec ) { main = 'hello.world.helloworld' }
here content of helloworld.groovy:
package hello.world class helloworld { public static void main(string[] args) { println "hello world!" } }
here shell:
testproject>$ gradle hello :compilejava up-to-date :compilegroovy up-to-date :processresources up-to-date :classes up-to-date :jar up-to-date :hello error: not find or load main class hello.world.helloworld :hello failed failure: build failed exception. * went wrong: execution failed task ':hello'. > process 'command '/library/java/javavirtualmachines/jdk1.7.0_25.jdk/contents/home/bin/java'' finished non-zero exit value 1 * try: run --stacktrace option stack trace. run --info or --debug option more log output. build failed total time: 4.232 secs
so, question is: how can make gradle hello
work? thank much.
after bit of googling, found solution. thing need change task block. working 1 pasted below:
task( hello, dependson: jar, type: javaexec ) { main = 'hello.world.helloworld' classpath = sourcesets.main.runtimeclasspath }
Comments
Post a Comment