8

I'd like to try Deadbolt. What are the steps to install it on the new Play Framework 2.2.1? What I found is resolvers and dependencies here. But where I have to put the resolvers? I don't want to use Build.scala (in Play 2.2 there's build.sbt)

And here is a line about plugin. Where it goes? In my project there isn't plugins.sbt and don't know if Play 2.2 prefers to put it elsewhere.

EDIT:

plugin.sbt

resolvers ++= Seq(
    "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
    Resolver.url("Objectify Play Repository", url("http://schaloner.github.io/releases/"))(Resolver.ivyStylePatterns),
    Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.io/snapshots/"))(Resolver.ivyStylePatterns)
)

build.sbt

    libraryDependencies ++= Seq(
      javaJdbc,
      javaEbean,
      cache,
      "mysql" % "mysql-connector-java" % "5.1.27",
      "org.apache.commons" % "commons-email" % "1.3.1",
      "be.objectify" %% "deadbolt-java" % "2.2-RC2"
    )    

Play console errors:

[info] Resolving org.hibernate.javax.persistence#hibernate-jpa-2.0-api;1.0.1.Fin[info] Resolving be.objectify#deadbolt-java_2.10;2.2-RC2 ...
[warn]  module not found: be.objectify#deadbolt-java_2.10;2.2-RC2
[warn] ==== local: tried
[warn]   /Users/johndoe/Applications/play-2.2.1/repository/local/be.objectify/deadbolt-java_2.10/2.2-RC2/ivys/ivy.xml
[warn] ==== Maven2 Local: tried
[warn]   file:/Users/johndoe/.m2/repository/be/objectify/deadbolt-java_2.10/2.2-RC2/deadbolt-java_2.10-2.2-RC2.pom
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/be/objectify/deadbolt-java_2.10/2.2-RC2/deadbolt-java_2.10-2.2-RC2.pom
[warn] ==== Typesafe Releases Repository: tried
[warn]   http://repo.typesafe.com/typesafe/releases/be/objectify/deadbolt-java_2.10/2.2-RC2/deadbolt-java_2.10-2.2-RC2.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: be.objectify#deadbolt-java_2.10;2.2-RC2: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: be.objectify#deadbolt-java_2.10;2.2-RC2: not found
[error] Total time: 3 s, completed 12-n
Fred K
  • 13,249
  • 14
  • 78
  • 103
  • Why are you avoiding Build.scala? Also, are you sure there is no plugins.sbt? The 2.2 documentation says it should be there. – Andrew Jones Nov 12 '13 at 13:43
  • No need to answer my question on `Build.scala`. After looking at the documentation, I see that it has been replaced. For your problem of not having `plugins.sbt`, you can try adding the file to the project/ directory. – Andrew Jones Nov 12 '13 at 13:54

3 Answers3

9

Dont add anything to plugins.sbt, following official documentation: https://github.com/schaloner/deadbolt-2/tree/master

Add to your build.sbt (without , and with one blank line)

resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.com/snapshots/"))(Resolver.ivyStylePatterns)

And

libraryDependencies ++= Seq(
  ...
  "be.objectify" %% "deadbolt-java" % "2.2-RC4",
  "be.objectify" %% "deadbolt-scala" % "2.2-RC2"
)

In time of writing im using play 2.2.1 and mine build.sbt is:

name := "crud-test"

version := "1.0-SNAPSHOT"

resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.com/snapshots/"))(Resolver.ivyStylePatterns)

libraryDependencies ++= Seq(
  javaJdbc,
  javaJpa,
  "org.postgresql" % "postgresql" % "9.2-1003-jdbc4",
  "org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final",
  "org.webjars" % "webjars-play_2.10" % "2.2.1",
  "org.webjars" % "bootstrap" % "3.1.0",
  "be.objectify" %% "deadbolt-java" % "2.2-RC4",
  "be.objectify" %% "deadbolt-scala" % "2.2-RC2"
)

play.Project.playJavaSettings

After running play reload and play eclipse from console:

...
[info] [SUCCESSFUL ]
[info] Done updating.
...

EDIT: Don't forget to do play reload and play eclipse after adding new dependencies to build.sbt

EDIT2: I guess that after Deadbolt you want to use play-authenticate system, because Deadbolt doesn’t provide authentication. You can find play-authenticate system on: https://github.com/joscha/play-authenticate.

With DeadBolt and play-authenticate system mine build.sbt is:

name := "crud-test"

version := "1.0-SNAPSHOT"

resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.com/snapshots/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("play-easymail (release)", url("http://joscha.github.com/play-easymail/repo/releases/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("play-easymail (snapshot)", url("http://joscha.github.com/play-easymail/repo/snapshots/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("play-authenticate (release)", url("http://joscha.github.com/play-authenticate/repo/releases/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("play-authenticate (snapshot)", url("http://joscha.github.com/play-authenticate/repo/snapshots/"))(Resolver.ivyStylePatterns)

libraryDependencies ++= Seq(
  javaJdbc,
  javaJpa,
  "org.postgresql" % "postgresql" % "9.2-1003-jdbc4",
  "org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final",
  "org.webjars" % "webjars-play_2.10" % "2.2.1" exclude("org.scala-lang", "scala-library"),
  "org.webjars" % "bootstrap" % "3.1.0",
  "be.objectify" %% "deadbolt-java" % "2.2-RC4",
  "be.objectify" %% "deadbolt-scala" % "2.2-RC2",
  "com.feth" %% "play-authenticate" % "0.5.0-SNAPSHOT"
)

play.Project.playJavaSettings
Srle
  • 10,366
  • 8
  • 34
  • 63
1

Try adding this to your build.sbt file. It resolved issues I was having with securesocial and postgresql dependencies:

resolvers += Resolver.url("sbt-plugin-releases", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
Shanker Kaura
  • 117
  • 1
  • 5
0

I'm not sure why you're not seeing plugins.sbt, but according to the 2.2.1 documentation, it should be there. http://www.playframework.com/documentation/2.2.1/Build

To add the dependencies to plugins.sbt, include the following lines in the file:

resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.io/releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.io/snapshots/"))(Resolver.ivyStylePatterns)

addSbtPlugin("be.objectify" %% "deadbolt-java" % "2.2-RC2")
addSbtPlugin("be.objectify" %% "deadbolt-scala" % "2.2-RC2")

Note: Depending on your project's needs, you may only need one of the two plugins.

Andrew Jones
  • 1,382
  • 10
  • 26
  • You may need to add the resolvers, as well. I'll edit my answer to include the syntax for adding those. – Andrew Jones Nov 12 '13 at 13:57
  • thanks. i've a doubt: `addSbtPlugin(string_here)` is equivalent to do this: `libraryDependencies ++= Seq(string_here)` in build.sbt file? – Fred K Nov 12 '13 at 14:01
  • That's correct. In the build file, a Seq is created and then addSbtPlugin (or a similar function) is applied to each item in the Seq. – Andrew Jones Nov 12 '13 at 14:05
  • Ok. Only one last theorical thing: I have to add both resolvers lines? What's the difference between them and why I need both? thanks! – Fred K Nov 12 '13 at 14:30
  • You likely don't need both of them. You can probably drop the second resolver and resolve your plugins just fine. Similarly, you may not need both deadbolt-scala and deadbolt-java (depending on your project). – Andrew Jones Nov 12 '13 at 14:38
  • Andrew, sorry but something's wrong. Take a look at errors in first post, please. – Fred K Nov 12 '13 at 15:18
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/41038/discussion-between-andrew-jones-and-fred-k) – Andrew Jones Nov 12 '13 at 17:30
  • Finally solved moving the resolvers to build.sbt. Not that good but it works. Waiting for better solutions. – Fred K Nov 13 '13 at 11:13