Whew… been learning a lot about gradle this evening, and I definitely like it. I’ll expand further with an in depth example, but for now just wanted to post a quick solution to something I was attempting to do. See, I wanted to be able to just type gradle run and have it run a single class from my project, but for some reason was having a difficult time figuring out how to make it work.

Luckily, gradle includes practically all the ant tasks so you can simply use ant.java:

task run(dependsOn:'build') <<{
        ant.java(classname: 'org.jamescarr.Main', fork: true,
        classpath: "${sourceSets.main.runtimeClasspath.asPath}")
}

We want it to depend on the build task so it will compile our classes and dependencies, then it’ll work as expected. :)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • BlogMemes
  • Blogosphere News
  • description
  • Fark
  • LinkedIn
  • NewsVine
  • StumbleUpon
  • Technorati
  • TwitThis
  • Yahoo! Buzz

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!