You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Alexis Midon <al...@gmail.com> on 2011/05/27 00:51:10 UTC
scala questions
Hello there,
I've been using scala in some projects and wanted to use the latest 2.9
version.
I hit some incompatibilities with version 2.8.1 around the compiler options
and the scalatest version. A patch is already drafted at
https://github.com/alexism/buildr/commits/scala_29
I wanted to share it with you. I'm sure I missed other compatibility issues
that you guys will catch.
I'll add some unit tests soon.
Also, I noticed that, in a same module, you can have sources in src/java and
in src/scala. They will be compiled and packaged in the same jar. Pretty
cool.
However it does not seem possible to do similar things with the unit tests.
Only the scalatest are executed, my java unit tests are ignored.
Am I missing something here? If it's actually not supported, what is your
strategy to test both java and scala sources?
Can scalatest run both?
thanks in advance,
Alexis
Re: scala questions
Posted by Alex Boisvert <al...@gmail.com>.
On Thu, May 26, 2011 at 6:18 PM, Alexis Midon <al...@gmail.com> wrote:
> It works fine except that you have to explicitly add scalatest to your test
> classpath.
>
>
> define 'scala-sample', :layout => server_layout do
> package :jar
> test.using :junit
> test.with
> "org.scalatest:scalatest_#{Scala.version}:jar:#{Scala::ScalaTest.version}"
> end
>
>
> I tried to have this done by the JUnit TestFramework but I don't see how to
> get access to the project language from the "dependencies" method.
> TestFramework don't know what project they are associated with.
>
> It looks that this information should be pass from outside.
> I gave a stab at a quick patch. Needs some polishing.
>
> https://github.com/alexism/buildr/commit/a40964f3e10198fadd9b6ab089010dee007d6e6a
Perhaps an after_define hook run in the ScalaTest module would be
easier/cleaner?
after_define(:scalatest => :test) do |project|
if (project.test.compile.language == :scala) && (project.test.framework
== :junit)
project.test.compile.dependencies += ScalaTest.dependencies
end
end
(just a sketch, untested)
alex
Re: scala questions
Posted by Alexis Midon <al...@gmail.com>.
It works fine except that you have to explicitly add scalatest to your test
classpath.
define 'scala-sample', :layout => server_layout do
package :jar
test.using :junit
test.with
"org.scalatest:scalatest_#{Scala.version}:jar:#{Scala::ScalaTest.version}"
end
I tried to have this done by the JUnit TestFramework but I don't see how to
get access to the project language from the "dependencies" method.
TestFramework don't know what project they are associated with.
It looks that this information should be pass from outside.
I gave a stab at a quick patch. Needs some polishing.
https://github.com/alexism/buildr/commit/a40964f3e10198fadd9b6ab089010dee007d6e6a
On Thu, May 26, 2011 at 4:03 PM, Alex Boisvert <al...@gmail.com>wrote:
> On Thu, May 26, 2011 at 3:51 PM, Alexis Midon <al...@gmail.com>
> wrote:
>
> > I've been using scala in some projects and wanted to use the latest 2.9
> > version.
> > I hit some incompatibilities with version 2.8.1 around the compiler
> options
> > and the scalatest version. A patch is already drafted at
> > https://github.com/alexism/buildr/commits/scala_29
> > I wanted to share it with you. I'm sure I missed other compatibility
> issues
> > that you guys will catch.
> >
>
> Cool, I have a similar patch locally so I'll merge both of our changes
> together and commit.
>
>
> > Also, I noticed that, in a same module, you can have sources in src/java
> > and
> > in src/scala. They will be compiled and packaged in the same jar. Pretty
> > cool.
> > However it does not seem possible to do similar things with the unit
> tests.
> > Only the scalatest are executed, my java unit tests are ignored.
> > Am I missing something here? If it's actually not supported, what is your
> > strategy to test both java and scala sources?
> >
>
> You can use JUnit to test both since ScalaTest can be wrapped as JUnit
> tests.
>
> http://www.scalatest.org/scaladoc-1.0/org/scalatest/junit/JUnitRunner.html
> <
> http://www.scalatest.org/scaladoc-1.0/org/scalatest/junit/JUnitRunner.html
> >
>
>
> > Can scalatest run both?
> >
>
> I don't believe so.
>
> alex
>
Re: scala questions
Posted by Alex Boisvert <al...@gmail.com>.
On Thu, May 26, 2011 at 3:51 PM, Alexis Midon <al...@gmail.com> wrote:
> I've been using scala in some projects and wanted to use the latest 2.9
> version.
> I hit some incompatibilities with version 2.8.1 around the compiler options
> and the scalatest version. A patch is already drafted at
> https://github.com/alexism/buildr/commits/scala_29
> I wanted to share it with you. I'm sure I missed other compatibility issues
> that you guys will catch.
>
Cool, I have a similar patch locally so I'll merge both of our changes
together and commit.
> Also, I noticed that, in a same module, you can have sources in src/java
> and
> in src/scala. They will be compiled and packaged in the same jar. Pretty
> cool.
> However it does not seem possible to do similar things with the unit tests.
> Only the scalatest are executed, my java unit tests are ignored.
> Am I missing something here? If it's actually not supported, what is your
> strategy to test both java and scala sources?
>
You can use JUnit to test both since ScalaTest can be wrapped as JUnit
tests.
http://www.scalatest.org/scaladoc-1.0/org/scalatest/junit/JUnitRunner.html
<http://www.scalatest.org/scaladoc-1.0/org/scalatest/junit/JUnitRunner.html>
> Can scalatest run both?
>
I don't believe so.
alex