On 11/07/10 12:41 AM, David Rosell wrote:
Since the Scala plugin doesn't recognize ScalaTest unit test's I call the Ant task "org.scalatest.tools.ScalaTestAntTask" However, I'm kind of groovy illiterate and do the gradle scripting copy past style and need some hints how to copy better :)

This is what I came up with:
task scalatest << {
          name: 'scalatest',
          classname: 'org.scalatest.tools.ScalaTestAntTask',
classpath: configurations.compile.asPath + ':' + compileScala.destinationDir
          runpath: 'build/classes/test',
          haltonfailure: 'true',
          fork: 'false'

1: I'm not happy about the runpath value, is there a better way to refere to the compiled tests?


2: Then there are tags inside the scalatest ant declaration (ie. reporter), how do I set these?

There's a chapter in the user guide about using Ant. Have a look at http://gradle.org/0.9-preview-3/docs/userguide/ant.html

Basically, you use nested method calls to add nested elements:

ant.scalatest(...) {
    reporter(type: 'stdout')

<target name="test" depends="">
<taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask">
<classpath refid="scalatest.classpath"/>
<*scalatest* runpath="${test.classes} " haltonfailure="true" fork="false">
*<reporter type="stdout" />*

3: I would like to snap my scalatest task into the test phase, how is this done?

You can simply replace the test task:

task test(overwrite: true, dependsOn: classes) << {

4: The scala build are a little slow, ~10sek can be a very long time when you do TDD, any tips on how to make it run faster?

I made some changes recently which should speed up multiproject scala builds. These changes will end up in the next release of Gradle. They won't make any difference to a single project build. We have also made a bunch of startup time improvements which may make a difference for your build.

Other than that, you could try using fsc rather than scalac. There are some settings on the ScalaCompileOptions class for enabling this.

There is currently a big startup cost when you are using Gradle to build Groovy or Scala projects. We plan to solve this at some point in a general purpose way, that can work for any type of project.

Last, I'd like to suggest adding something like this scalatest task to the Scala Plugin section in the documentation, it is nice to have working examples how to extend gradle's capabilities in context, and now that the "run a program" is fixed so that you doesn't need ant for that, this could be another...

I think I'd rather add ScalaTest support to the test task. I've added an issue for this: http://jira.codehaus.org/browse/GRADLE-1032

Adam Murdoch
Gradle Developer
CTO, Gradle Inc. - Gradle Training, Support, Consulting

Reply via email to