Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Play’s Build.scala File- a Very Subtle Gotcha

DZone's Guide to

Play’s Build.scala File- a Very Subtle Gotcha

· Java Zone
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

Work on the new module repository for Play is progressing nicely, but a very subtle bug was introduced into the Build.scala file. As a result, artifacts from the first repository were not being found. Can you spot the difference here? The first code snippet is correct, and the second is faulty.

val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings (
    resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns),
    resolvers += Resolver.url("Scala Tools", url("http://scala-tools.org/repo-releases/"))(Resolver.ivyStylePatterns)
  )
val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings {
    resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns)
    resolvers += Resolver.url("Scala Tools", url("http://scala-tools.org/repo-releases/"))(Resolver.ivyStylePatterns)
  }

The problem was caused by using curly brackets instead of parentheses. Note also that when using curly brackets, you can’t put a comma after the first resolver. However, the file still compiles without a problem. Very subtle, very annoying!

So, the correct form is the first snippet above – here with bold to emphasise the key points.

val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings (
    resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns),
    resolvers += Resolver.url("Scala Tools", url("http://scala-tools.org/repo-releases/"))(Resolver.ivyStylePatterns)
  )

 

 

 

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:

Published at DZone with permission of Steve Chaloner, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}