From afc8bf2070ddbf743e6fc8808fbe1e8f97ed0914 Mon Sep 17 00:00:00 2001 From: Renato Cavalcanti Date: Fri, 16 Nov 2018 15:25:15 +0100 Subject: [PATCH 01/18] Updated with template-control on 2018-11-16T14:25:15.823Z **/plugins.sbt: addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.0-RC3") **/plugins.sbt: addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "5.0.0-RC1") --- project/plugins.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 222d5e8..aac817e 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.20") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.0-RC3") -addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "4.1.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "5.0.0-RC1") From 875afade92a3d043393640f7535f3ef902a4ec23 Mon Sep 17 00:00:00 2001 From: Ignasi Marimon-Clos Date: Thu, 29 Nov 2018 17:03:52 +0100 Subject: [PATCH 02/18] Partial commit. blocked until #8827 is released in 2.7.0-RC8 --- app/controllers/HomeController.java | 5 +++-- app/views/createForm.scala.html | 5 +++-- app/views/list.scala.html | 7 ++++--- build.sbt | 9 ++++++--- conf/routes | 2 +- project/plugins.sbt | 2 -- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/controllers/HomeController.java b/app/controllers/HomeController.java index a13d0f3..51414ea 100644 --- a/app/controllers/HomeController.java +++ b/app/controllers/HomeController.java @@ -5,6 +5,7 @@ import play.data.FormFactory; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Controller; +import play.mvc.Http; import play.mvc.Result; import play.mvc.Results; import repository.CompanyRepository; @@ -58,11 +59,11 @@ public Result index() { * @param order Sort order (either asc or desc) * @param filter Filter applied on computer names */ - public CompletionStage list(int page, String sortBy, String order, String filter) { + public CompletionStage list(Http.Request request, int page, String sortBy, String order, String filter) { // Run a db operation in another thread (using DatabaseExecutionContext) return computerRepository.page(page, 10, sortBy, order, filter).thenApplyAsync(list -> { // This is the HTTP rendering thread context - return ok(views.html.list.render(list, sortBy, order, filter)); + return ok(views.html.list.render(list, sortBy, order, filter, request.asScala())); }, httpExecutionContext.current()); } diff --git a/app/views/createForm.scala.html b/app/views/createForm.scala.html index 9d07b87..855a39d 100644 --- a/app/views/createForm.scala.html +++ b/app/views/createForm.scala.html @@ -1,4 +1,5 @@ -@(computerForm: Form[Computer], companies: Map[String, String]) +@import play.api.mvc.RequestHeader +@(computerForm: Form[Computer], companies: Map[String, String])(implicit request:RequestHeader) @import helper._ @@ -24,7 +25,7 @@

Add a computer

or - Cancel + Cancel
} diff --git a/app/views/list.scala.html b/app/views/list.scala.html index 2bf3ce0..dc2c5dc 100644 --- a/app/views/list.scala.html +++ b/app/views/list.scala.html @@ -1,4 +1,5 @@ -@(currentPage: io.ebean.PagedList[Computer], currentSortBy: String, currentOrder: String, currentFilter: String) +@import play.api.mvc.RequestHeader +@(currentPage: io.ebean.PagedList[Computer], currentSortBy: String, currentOrder: String, currentFilter: String)(request:RequestHeader) @**************************************** * Helper generating navigation links * @@ -39,9 +40,9 @@

@Messages("computers.list.title", currentPage.getTotalCount)

- @if(flash.containsKey("success")) { + @request.flash.get("success").map { successFlashValue =>
- Done! @flash.get("success") + Done! @successFlashValue
} diff --git a/build.sbt b/build.sbt index 169647f..aa567f8 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,7 @@ name := "play-java-ebean-example" version := "1.0.0-SNAPSHOT" -scalaVersion := "2.12.6" - -crossScalaVersions := Seq("2.11.12", "2.12.6") +scalaVersion := "2.12.7" lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean) @@ -16,3 +14,8 @@ libraryDependencies += "org.awaitility" % "awaitility" % "2.0.0" % Test libraryDependencies += "org.assertj" % "assertj-core" % "3.6.2" % Test libraryDependencies += "org.mockito" % "mockito-core" % "2.1.0" % Test testOptions in Test += Tests.Argument(TestFrameworks.JUnit, "-a", "-v") + +javacOptions ++= Seq( + "-Xlint:unchecked", + "-Xlint:deprecation" +) \ No newline at end of file diff --git a/conf/routes b/conf/routes index 17365b2..cb53f8d 100644 --- a/conf/routes +++ b/conf/routes @@ -6,7 +6,7 @@ GET / controllers.HomeController.index() # Computers list (look at the default values for pagination parameters) -GET /computers controllers.HomeController.list(p:Int ?= 0, s ?= "name", o ?= "asc", f ?= "") +GET /computers controllers.HomeController.list(request: Request, p:Int ?= 0, s ?= "name", o ?= "asc", f ?= "") # Add computer GET /computers/new controllers.HomeController.create() diff --git a/project/plugins.sbt b/project/plugins.sbt index aac817e..3f085d9 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,3 @@ -resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" - // The Play plugin addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.0-RC3") From a1ed5852305815de0a8060a8430af2ceaad4a742 Mon Sep 17 00:00:00 2001 From: Ignasi Marimon-Clos Date: Thu, 29 Nov 2018 22:06:13 +0100 Subject: [PATCH 03/18] Bump to RC8 and fix compilation errors. --- app/controllers/HomeController.java | 22 +++++++++++++--------- app/views/createForm.scala.html | 6 +++--- app/views/list.scala.html | 4 ++-- conf/routes | 6 +++--- project/plugins.sbt | 4 ++-- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/controllers/HomeController.java b/app/controllers/HomeController.java index 51414ea..1b84b50 100644 --- a/app/controllers/HomeController.java +++ b/app/controllers/HomeController.java @@ -3,6 +3,7 @@ import models.Computer; import play.data.Form; import play.data.FormFactory; +import play.i18n.MessagesApi; import play.libs.concurrent.HttpExecutionContext; import play.mvc.Controller; import play.mvc.Http; @@ -25,16 +26,19 @@ public class HomeController extends Controller { private final CompanyRepository companyRepository; private final FormFactory formFactory; private final HttpExecutionContext httpExecutionContext; + private MessagesApi messagesApi; @Inject public HomeController(FormFactory formFactory, ComputerRepository computerRepository, CompanyRepository companyRepository, - HttpExecutionContext httpExecutionContext) { + HttpExecutionContext httpExecutionContext, + MessagesApi messagesApi) { this.computerRepository = computerRepository; this.formFactory = formFactory; this.companyRepository = companyRepository; this.httpExecutionContext = httpExecutionContext; + this.messagesApi = messagesApi; } /** @@ -63,7 +67,7 @@ public CompletionStage list(Http.Request request, int page, String sortB // Run a db operation in another thread (using DatabaseExecutionContext) return computerRepository.page(page, 10, sortBy, order, filter).thenApplyAsync(list -> { // This is the HTTP rendering thread context - return ok(views.html.list.render(list, sortBy, order, filter, request.asScala())); + return ok(views.html.list.render(list, sortBy, order, filter, request, messagesApi.preferred(request))); }, httpExecutionContext.current()); } @@ -91,8 +95,8 @@ public CompletionStage edit(Long id) { * * @param id Id of the computer to edit */ - public CompletionStage update(Long id) throws PersistenceException { - Form computerForm = formFactory.form(Computer.class).bindFromRequest(); + public CompletionStage update(Http.Request request, Long id) throws PersistenceException { + Form computerForm = formFactory.form(Computer.class).bindFromRequest(request); if (computerForm.hasErrors()) { // Run companies db operation and then render the failure case return companyRepository.options().thenApplyAsync(companies -> { @@ -113,25 +117,25 @@ public CompletionStage update(Long id) throws PersistenceException { /** * Display the 'new computer form'. */ - public CompletionStage create() { + public CompletionStage create(Http.Request request) { Form computerForm = formFactory.form(Computer.class); // Run companies db operation and then render the form return companyRepository.options().thenApplyAsync((Map companies) -> { // This is the HTTP rendering thread context - return ok(views.html.createForm.render(computerForm, companies)); + return ok(views.html.createForm.render(computerForm, companies, request, messagesApi.preferred(request))); }, httpExecutionContext.current()); } /** * Handle the 'new computer form' submission */ - public CompletionStage save() { - Form computerForm = formFactory.form(Computer.class).bindFromRequest(); + public CompletionStage save(Http.Request request) { + Form computerForm = formFactory.form(Computer.class).bindFromRequest(request); if (computerForm.hasErrors()) { // Run companies db operation and then render the form return companyRepository.options().thenApplyAsync(companies -> { // This is the HTTP rendering thread context - return badRequest(views.html.createForm.render(computerForm, companies)); + return badRequest(views.html.createForm.render(computerForm, companies, request, messagesApi.preferred(request))); }, httpExecutionContext.current()); } diff --git a/app/views/createForm.scala.html b/app/views/createForm.scala.html index 855a39d..e0e6e82 100644 --- a/app/views/createForm.scala.html +++ b/app/views/createForm.scala.html @@ -1,5 +1,5 @@ -@import play.api.mvc.RequestHeader -@(computerForm: Form[Computer], companies: Map[String, String])(implicit request:RequestHeader) +@import play.mvc.Http.Request +@(computerForm: Form[Computer], companies: Map[String, String])(implicit request: Request, messages: play.i18n.Messages) @import helper._ @@ -25,7 +25,7 @@

Add a computer

or - Cancel + Cancel
} diff --git a/app/views/list.scala.html b/app/views/list.scala.html index dc2c5dc..ee31a8d 100644 --- a/app/views/list.scala.html +++ b/app/views/list.scala.html @@ -1,5 +1,5 @@ -@import play.api.mvc.RequestHeader -@(currentPage: io.ebean.PagedList[Computer], currentSortBy: String, currentOrder: String, currentFilter: String)(request:RequestHeader) +@import play.mvc.Http.Request +@(currentPage: io.ebean.PagedList[Computer], currentSortBy: String, currentOrder: String, currentFilter: String)(implicit request: Request, messages: play.i18n.Messages)) @**************************************** * Helper generating navigation links * diff --git a/conf/routes b/conf/routes index cb53f8d..e454ac9 100644 --- a/conf/routes +++ b/conf/routes @@ -9,12 +9,12 @@ GET / controllers.HomeController.index() GET /computers controllers.HomeController.list(request: Request, p:Int ?= 0, s ?= "name", o ?= "asc", f ?= "") # Add computer -GET /computers/new controllers.HomeController.create() -POST /computers controllers.HomeController.save() +GET /computers/new controllers.HomeController.create(request: Request) +POST /computers controllers.HomeController.save(request: Request) # Edit existing computer GET /computers/:id controllers.HomeController.edit(id:Long) -POST /computers/:id controllers.HomeController.update(id:Long) +POST /computers/:id controllers.HomeController.update(request: Request, id:Long) # Delete a computer POST /computers/:id/delete controllers.HomeController.delete(id:Long) diff --git a/project/plugins.sbt b/project/plugins.sbt index 3f085d9..85f0ff7 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.0-RC3") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.0-RC8") -addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "5.0.0-RC1") +addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "5.0.0-RC2") From 922644fb29a26a4b3dfab4e29b663f537172814d Mon Sep 17 00:00:00 2001 From: Ignasi Marimon-Clos Date: Thu, 29 Nov 2018 22:28:29 +0100 Subject: [PATCH 04/18] Some more deprecation fixes. --- app/controllers/HomeController.java | 20 ++++++++++---------- app/views/editForm.scala.html | 3 ++- app/views/list.scala.html | 9 +++++++-- conf/routes | 2 +- test/FunctionalTest.java | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/controllers/HomeController.java b/app/controllers/HomeController.java index 1b84b50..d53aa1d 100644 --- a/app/controllers/HomeController.java +++ b/app/controllers/HomeController.java @@ -45,7 +45,7 @@ public HomeController(FormFactory formFactory, * This result directly redirect to application home. */ private Result GO_HOME = Results.redirect( - routes.HomeController.list(0, "name", "asc", "") + routes.HomeController.list(0, "name", "asc", "") ); /** @@ -76,7 +76,7 @@ public CompletionStage list(Http.Request request, int page, String sortB * * @param id Id of the computer to edit */ - public CompletionStage edit(Long id) { + public CompletionStage edit(Http.Request request,Long id) { // Run a db operation in another thread (using DatabaseExecutionContext) CompletionStage> companiesFuture = companyRepository.options(); @@ -86,7 +86,7 @@ public CompletionStage edit(Long id) { // This is the HTTP rendering thread context Computer c = computerOptional.get(); Form computerForm = formFactory.form(Computer.class).fill(c); - return ok(views.html.editForm.render(id, computerForm, companies)); + return ok(views.html.editForm.render(id, computerForm, companies, request, messagesApi.preferred(request))); }, httpExecutionContext.current()); } @@ -101,15 +101,15 @@ public CompletionStage update(Http.Request request, Long id) throws Pers // Run companies db operation and then render the failure case return companyRepository.options().thenApplyAsync(companies -> { // This is the HTTP rendering thread context - return badRequest(views.html.editForm.render(id, computerForm, companies)); + return badRequest(views.html.editForm.render(id, computerForm, companies, request, messagesApi.preferred(request))); }, httpExecutionContext.current()); } else { Computer newComputerData = computerForm.get(); // Run update operation and then flash and then redirect return computerRepository.update(id, newComputerData).thenApplyAsync(data -> { // This is the HTTP rendering thread context - flash("success", "Computer " + newComputerData.name + " has been updated"); - return GO_HOME; + return GO_HOME + .flash("success", "Computer " + newComputerData.name + " has been updated"); }, httpExecutionContext.current()); } } @@ -143,8 +143,8 @@ public CompletionStage save(Http.Request request) { // Run insert db operation, then redirect return computerRepository.insert(computer).thenApplyAsync(data -> { // This is the HTTP rendering thread context - flash("success", "Computer " + computer.name + " has been created"); - return GO_HOME; + return GO_HOME + .flash("success", "Computer " + computer.name + " has been created"); }, httpExecutionContext.current()); } @@ -155,8 +155,8 @@ public CompletionStage delete(Long id) { // Run delete db operation, then redirect return computerRepository.delete(id).thenApplyAsync(v -> { // This is the HTTP rendering thread context - flash("success", "Computer has been deleted"); - return GO_HOME; + return GO_HOME + .flash("success", "Computer has been deleted"); }, httpExecutionContext.current()); } diff --git a/app/views/editForm.scala.html b/app/views/editForm.scala.html index 8e9f4a4..f4bff5f 100644 --- a/app/views/editForm.scala.html +++ b/app/views/editForm.scala.html @@ -1,4 +1,5 @@ -@(id: Long, computerForm: Form[Computer], companies: Map[String, String]) +@import play.mvc.Http.Request +@(id: Long, computerForm: Form[Computer], companies: Map[String, String])(implicit request: Request, messages: play.i18n.Messages) @import helper._ diff --git a/app/views/list.scala.html b/app/views/list.scala.html index ee31a8d..1b637d9 100644 --- a/app/views/list.scala.html +++ b/app/views/list.scala.html @@ -1,5 +1,10 @@ @import play.mvc.Http.Request -@(currentPage: io.ebean.PagedList[Computer], currentSortBy: String, currentOrder: String, currentFilter: String)(implicit request: Request, messages: play.i18n.Messages)) +@(currentPage: io.ebean.PagedList[Computer], + currentSortBy: String, + currentOrder: String, + currentFilter: String)( + implicit request: Request, + messages: play.i18n.Messages) @**************************************** * Helper generating navigation links * @@ -40,7 +45,7 @@

@Messages("computers.list.title", currentPage.getTotalCount)

- @request.flash.get("success").map { successFlashValue => + @request.flash.asScala().get("success").map { successFlashValue =>
Done! @successFlashValue
diff --git a/conf/routes b/conf/routes index e454ac9..de7e1b3 100644 --- a/conf/routes +++ b/conf/routes @@ -13,7 +13,7 @@ GET /computers/new controllers.HomeController.create(request: R POST /computers controllers.HomeController.save(request: Request) # Edit existing computer -GET /computers/:id controllers.HomeController.edit(id:Long) +GET /computers/:id controllers.HomeController.edit(request: Request, id:Long) POST /computers/:id controllers.HomeController.update(request: Request, id:Long) # Delete a computer diff --git a/test/FunctionalTest.java b/test/FunctionalTest.java index c426e4a..1f3b424 100644 --- a/test/FunctionalTest.java +++ b/test/FunctionalTest.java @@ -65,7 +65,7 @@ public void createANewComputer() { assertThat(result.status()).isEqualTo(SEE_OTHER); assertThat(result.redirectLocation().get()).isEqualTo("/computers"); - assertThat(result.flash().get("success")).isEqualTo("Computer FooBar has been created"); + assertThat(result.flash().getOptional("success").get()).isEqualTo("Computer FooBar has been created"); result = route(app, controllers.routes.HomeController.list(0, "name", "asc", "FooBar")); assertThat(result.status()).isEqualTo(OK); From 8895d93f4795833b4970d486181d9d7c4dfc0f26 Mon Sep 17 00:00:00 2001 From: Ignasi Marimon-Clos Date: Thu, 29 Nov 2018 23:18:33 +0100 Subject: [PATCH 05/18] Avoid polluting the working folder. --- test/BrowserTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/BrowserTest.java b/test/BrowserTest.java index c9a2e0e..d19ca4e 100644 --- a/test/BrowserTest.java +++ b/test/BrowserTest.java @@ -52,7 +52,7 @@ public void testBrowser() { browser.$("a", withText("Apple II")).click(); browser.$("input.danger").click(); - browser.takeHtmlDump("delete.html"); + browser.takeHtmlDump("target/delete.html"); assertThat(browser.$("section h1").first().text(), equalTo("573 computers found")); assertThat(browser.$(".alert-message").first().text(), equalTo("Done! Computer has been deleted")); From 1293504227a203595c69a42ef886a3da46ec2371 Mon Sep 17 00:00:00 2001 From: Ignasi Marimon-Clos Date: Fri, 30 Nov 2018 12:22:23 +0100 Subject: [PATCH 06/18] Update travis to last generation (see other sample apps) --- .travis.yml | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index c033a48..5b51cde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,40 @@ -dist: trusty -sudo: true -group: beta language: scala scala: -- 2.11.11 -- 2.12.3 + - 2.12.7 jdk: -- oraclejdk8 + - oraclejdk8 + - openjdk11 +env: + matrix: + - SCRIPT=scripts/test-sbt + - SCRIPT=scripts/test-gradle +script: + - $SCRIPT cache: directories: - - "$HOME/.ivy2/cache" - - "$HOME/.sbt/launchers" + - "$HOME/.ivy2/cache" + - "$HOME/.gradle/caches" before_cache: -- rm -rf $HOME/.ivy2/cache/com.typesafe.play/* -- rm -rf $HOME/.ivy2/cache/scala_*/sbt_*/com.typesafe.play/* -- find $HOME/.ivy2/cache -name "ivydata-*.properties" -print0 | xargs -n10 -0 rm + - rm -rf $HOME/.ivy2/cache/com.typesafe.play/* + - rm -rf $HOME/.ivy2/cache/scala_*/sbt_*/com.typesafe.play/* + - find $HOME/.ivy2/cache -name "ivydata-*.properties" -print0 | xargs -n10 -0 rm + +# Exclude some combinations from build matrix. See: +# https://docs.travis-ci.com/user/customizing-the-build/#Build-Matrix +matrix: + fast_finish: true + allow_failures: + # Current release of Gradle still does not supports Play 2.7.x releases + # As soon as there is a release of Gradle that fixes that, we can then + # remove this allowed failure. + - env: SCRIPT=scripts/test-gradle + # Java 11 is still not fully supported. It is good that we are already + # testing our sample applications to better discover possible problems + # but we can allow failures here too. + - jdk: openjdk11 + +# See https://blog.travis-ci.com/2014-03-13-slack-notifications/ +# created with travis encrypt command line tool notifications: slack: - secure: K6HWTI6zJpQfxS7sH5ZQ1jEK5TkkUl5GtcGinNecHMBqvfS4IXAnU23lz/kLqCqMVPIFaRx1g6UwgJgMvR4XWeIhpzLOzAnOOcmv+kQzv7A8vEJBM20z1HNzDcxzvuNNO2BHn8EjXh5VD65vXMcA+lKzUxASey/Rs+CBReQWE7M= + secure: ltgIyHnWM/apr/VaeX9diKH6o4chcZO+1SUmjTuJIoRJCMdKjv0TY4k+HMabLwe/4ZXhzZ/nq2VhbUZDnvsL90b9MfeDjcvf9ku20MSNuiDvZZC3yYgj7I+x3Y2kbVZcugTPbl2Ig0UGqSGCuVyqYnLSBPQ1LOn/gug3hGMqcJ5vb40g1zRPG842yZjJ5UTo5suitPc63YYuAcddoBnBCqAez+2Z8W4Gf6vu27DonTEcisiu2MmWD2X2AqmahuZi7TE0c3o3CBrrY38N+EPvonuBHSO03vaCF0XvabOxALHzLQDG6byw/u4anGXpa0/dhrT6gglb31y10hzxH6yfb2p9a/LNrY4gKyz4bzEBplTb7uogaJCJpYiQDdINxRGkVdbHRDyuAsEo+Y7y6pW60oEOLUuLmvKSAjPNp5k1o2Mmx13O1SBbAxP6YSiZStptKYko8BlSEIsBSvhXaZuIcoAeMgypcxyemZWi9QBIH+SNgueIdGCTBZ5lQe+nBLhjft+0hFnV9mJMazGmvaue5UGukalLhHgyNhnGdTrC1QVjU53iDY95GY3QJhcdnXr6cCvEAZvHwefjnTLCiKqNAgG77Y3w8CH5vyFwoS/dYFzl08urIxblxL8bUrI5vgNrt38gW/vKHxXZBzj6c80xyfdVGcdex/m/jI5BllLMH3A= From 7a17822c92ffa80aca2325ea8671ea87bd8e6800 Mon Sep 17 00:00:00 2001 From: Ignasi Marimon-Clos Date: Fri, 30 Nov 2018 14:24:36 +0100 Subject: [PATCH 07/18] Adds scripts/ for the new travis jobs defintions. Disables gradle job --- .travis.yml | 2 +- scripts/script-helper | 13 +++++++++++++ scripts/test-sbt | 8 ++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 scripts/script-helper create mode 100755 scripts/test-sbt diff --git a/.travis.yml b/.travis.yml index 5b51cde..5167133 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ jdk: env: matrix: - SCRIPT=scripts/test-sbt - - SCRIPT=scripts/test-gradle +# - SCRIPT=scripts/test-gradle script: - $SCRIPT cache: diff --git a/scripts/script-helper b/scripts/script-helper new file mode 100644 index 0000000..9a2faa6 --- /dev/null +++ b/scripts/script-helper @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +java_version=$(java -version 2>&1 | java -version 2>&1 | awk -F '"' '/version/ {print $2}') + +if [[ $java_version = 1.8* ]] ; then + echo "The build is using Java 8 ($java_version). No addional JVM params needed." +else + echo "The build is using Java 9+ ($java_version). We need additional JVM parameters" + export _JAVA_OPTIONS="$_JAVA_OPTIONS --add-modules=java.xml.bind" +fi diff --git a/scripts/test-sbt b/scripts/test-sbt new file mode 100755 index 0000000..0425367 --- /dev/null +++ b/scripts/test-sbt @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +. "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/script-helper" + +echo "+----------------------------+" +echo "| Executing tests using sbt |" +echo "+----------------------------+" +sbt ++$TRAVIS_SCALA_VERSION test From 1fe8ce48545a1b800230ad19f5141868172a0494 Mon Sep 17 00:00:00 2001 From: Ignasi Marimon-Clos Date: Fri, 30 Nov 2018 22:27:22 +0100 Subject: [PATCH 08/18] Simplify imports --- app/views/createForm.scala.html | 3 +-- app/views/editForm.scala.html | 3 +-- app/views/list.scala.html | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/views/createForm.scala.html b/app/views/createForm.scala.html index e0e6e82..ac6eae0 100644 --- a/app/views/createForm.scala.html +++ b/app/views/createForm.scala.html @@ -1,5 +1,4 @@ -@import play.mvc.Http.Request -@(computerForm: Form[Computer], companies: Map[String, String])(implicit request: Request, messages: play.i18n.Messages) +@(computerForm: Form[Computer], companies: Map[String, String])(implicit request: Http.Request, messages: play.i18n.Messages) @import helper._ diff --git a/app/views/editForm.scala.html b/app/views/editForm.scala.html index f4bff5f..1384530 100644 --- a/app/views/editForm.scala.html +++ b/app/views/editForm.scala.html @@ -1,5 +1,4 @@ -@import play.mvc.Http.Request -@(id: Long, computerForm: Form[Computer], companies: Map[String, String])(implicit request: Request, messages: play.i18n.Messages) +@(id: Long, computerForm: Form[Computer], companies: Map[String, String])(implicit request: Http.Request, messages: play.i18n.Messages) @import helper._ diff --git a/app/views/list.scala.html b/app/views/list.scala.html index 1b637d9..a984eda 100644 --- a/app/views/list.scala.html +++ b/app/views/list.scala.html @@ -1,9 +1,8 @@ -@import play.mvc.Http.Request @(currentPage: io.ebean.PagedList[Computer], currentSortBy: String, currentOrder: String, currentFilter: String)( - implicit request: Request, + implicit request: Http.Request, messages: play.i18n.Messages) @**************************************** From 4fddd101211ec9b6e4dd8c671cdde3ac97e32426 Mon Sep 17 00:00:00 2001 From: Grzegorz Slowikowski Date: Mon, 3 Dec 2018 11:14:41 +0100 Subject: [PATCH 09/18] Update app/controllers/HomeController.java Co-Authored-By: renatocaval --- app/controllers/HomeController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/HomeController.java b/app/controllers/HomeController.java index d53aa1d..efd39ce 100644 --- a/app/controllers/HomeController.java +++ b/app/controllers/HomeController.java @@ -26,7 +26,7 @@ public class HomeController extends Controller { private final CompanyRepository companyRepository; private final FormFactory formFactory; private final HttpExecutionContext httpExecutionContext; - private MessagesApi messagesApi; + private final MessagesApi messagesApi; @Inject public HomeController(FormFactory formFactory, From de19bce013c8749cca7b8395465f9fef346cf210 Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Thu, 6 Dec 2018 08:57:04 -0500 Subject: [PATCH 10/18] Removing Gradle from Travis configuration --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5167133..397939a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ jdk: env: matrix: - SCRIPT=scripts/test-sbt -# - SCRIPT=scripts/test-gradle script: - $SCRIPT cache: @@ -24,10 +23,6 @@ before_cache: matrix: fast_finish: true allow_failures: - # Current release of Gradle still does not supports Play 2.7.x releases - # As soon as there is a release of Gradle that fixes that, we can then - # remove this allowed failure. - - env: SCRIPT=scripts/test-gradle # Java 11 is still not fully supported. It is good that we are already # testing our sample applications to better discover possible problems # but we can allow failures here too. From 0c35ad677d96789d3b6cf1b140dbccc402077dce Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Thu, 6 Dec 2018 08:58:08 -0500 Subject: [PATCH 11/18] Revert slack notification key setting --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 397939a..1ea27a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ script: cache: directories: - "$HOME/.ivy2/cache" - - "$HOME/.gradle/caches" before_cache: - rm -rf $HOME/.ivy2/cache/com.typesafe.play/* - rm -rf $HOME/.ivy2/cache/scala_*/sbt_*/com.typesafe.play/* @@ -32,4 +31,4 @@ matrix: # created with travis encrypt command line tool notifications: slack: - secure: ltgIyHnWM/apr/VaeX9diKH6o4chcZO+1SUmjTuJIoRJCMdKjv0TY4k+HMabLwe/4ZXhzZ/nq2VhbUZDnvsL90b9MfeDjcvf9ku20MSNuiDvZZC3yYgj7I+x3Y2kbVZcugTPbl2Ig0UGqSGCuVyqYnLSBPQ1LOn/gug3hGMqcJ5vb40g1zRPG842yZjJ5UTo5suitPc63YYuAcddoBnBCqAez+2Z8W4Gf6vu27DonTEcisiu2MmWD2X2AqmahuZi7TE0c3o3CBrrY38N+EPvonuBHSO03vaCF0XvabOxALHzLQDG6byw/u4anGXpa0/dhrT6gglb31y10hzxH6yfb2p9a/LNrY4gKyz4bzEBplTb7uogaJCJpYiQDdINxRGkVdbHRDyuAsEo+Y7y6pW60oEOLUuLmvKSAjPNp5k1o2Mmx13O1SBbAxP6YSiZStptKYko8BlSEIsBSvhXaZuIcoAeMgypcxyemZWi9QBIH+SNgueIdGCTBZ5lQe+nBLhjft+0hFnV9mJMazGmvaue5UGukalLhHgyNhnGdTrC1QVjU53iDY95GY3QJhcdnXr6cCvEAZvHwefjnTLCiKqNAgG77Y3w8CH5vyFwoS/dYFzl08urIxblxL8bUrI5vgNrt38gW/vKHxXZBzj6c80xyfdVGcdex/m/jI5BllLMH3A= + secure: K6HWTI6zJpQfxS7sH5ZQ1jEK5TkkUl5GtcGinNecHMBqvfS4IXAnU23lz/kLqCqMVPIFaRx1g6UwgJgMvR4XWeIhpzLOzAnOOcmv+kQzv7A8vEJBM20z1HNzDcxzvuNNO2BHn8EjXh5VD65vXMcA+lKzUxASey/Rs+CBReQWE7M= From 94a91f7fc9bd3d27a6786b5820edb3a6d59fe14e Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Thu, 6 Dec 2018 08:59:06 -0500 Subject: [PATCH 12/18] Remove reference to script-helper --- scripts/test-sbt | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/test-sbt b/scripts/test-sbt index 0425367..46be3f9 100755 --- a/scripts/test-sbt +++ b/scripts/test-sbt @@ -1,7 +1,5 @@ #!/usr/bin/env bash -. "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/script-helper" - echo "+----------------------------+" echo "| Executing tests using sbt |" echo "+----------------------------+" From ab22bc194cf8236ccf62a7e5f083bea487389322 Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Thu, 6 Dec 2018 08:59:30 -0500 Subject: [PATCH 13/18] Remove script-helper since it is not necessary --- scripts/script-helper | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 scripts/script-helper diff --git a/scripts/script-helper b/scripts/script-helper deleted file mode 100644 index 9a2faa6..0000000 --- a/scripts/script-helper +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -java_version=$(java -version 2>&1 | java -version 2>&1 | awk -F '"' '/version/ {print $2}') - -if [[ $java_version = 1.8* ]] ; then - echo "The build is using Java 8 ($java_version). No addional JVM params needed." -else - echo "The build is using Java 9+ ($java_version). We need additional JVM parameters" - export _JAVA_OPTIONS="$_JAVA_OPTIONS --add-modules=java.xml.bind" -fi From 368b65a059ddfa73077b299fac036bfa3033ddfd Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Thu, 6 Dec 2018 09:01:27 -0500 Subject: [PATCH 14/18] Idiomatic use of flash in views --- app/views/list.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/list.scala.html b/app/views/list.scala.html index a984eda..aac309e 100644 --- a/app/views/list.scala.html +++ b/app/views/list.scala.html @@ -44,7 +44,7 @@

@Messages("computers.list.title", currentPage.getTotalCount)

- @request.flash.asScala().get("success").map { successFlashValue => + @flash("success").map { successFlashValue =>
Done! @successFlashValue
From 966ab5572ea488a4cdd38712deb3a44ef289d4e0 Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Thu, 6 Dec 2018 09:02:06 -0500 Subject: [PATCH 15/18] Add -Werror --- build.sbt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index aa567f8..9e856db 100644 --- a/build.sbt +++ b/build.sbt @@ -15,7 +15,4 @@ libraryDependencies += "org.assertj" % "assertj-core" % "3.6.2" % Test libraryDependencies += "org.mockito" % "mockito-core" % "2.1.0" % Test testOptions in Test += Tests.Argument(TestFrameworks.JUnit, "-a", "-v") -javacOptions ++= Seq( - "-Xlint:unchecked", - "-Xlint:deprecation" -) \ No newline at end of file +javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation", "-Werror") From 9092f57a67ce88aebb3828d6a7d0853252076b12 Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Mon, 10 Dec 2018 14:53:12 -0500 Subject: [PATCH 16/18] Using the request to access flash --- app/views/list.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/list.scala.html b/app/views/list.scala.html index aac309e..c921bf0 100644 --- a/app/views/list.scala.html +++ b/app/views/list.scala.html @@ -44,7 +44,7 @@

@Messages("computers.list.title", currentPage.getTotalCount)

- @flash("success").map { successFlashValue => + @request.flash("success").map { successFlashValue =>
Done! @successFlashValue
From 153c5773524072981fc46a09879da1c8734421d1 Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Thu, 20 Dec 2018 16:13:17 -0500 Subject: [PATCH 17/18] Fix compile problem --- app/views/list.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/list.scala.html b/app/views/list.scala.html index c921bf0..6a05508 100644 --- a/app/views/list.scala.html +++ b/app/views/list.scala.html @@ -44,7 +44,7 @@

@Messages("computers.list.title", currentPage.getTotalCount)

- @request.flash("success").map { successFlashValue => + @request.flash.apply("success").map { successFlashValue =>
Done! @successFlashValue
From 92d0ebc933a3fb9a1f9f336313c77110bc15a7e4 Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Thu, 20 Dec 2018 16:27:49 -0500 Subject: [PATCH 18/18] Update list.scala.html --- app/views/list.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/list.scala.html b/app/views/list.scala.html index 6a05508..a984eda 100644 --- a/app/views/list.scala.html +++ b/app/views/list.scala.html @@ -44,7 +44,7 @@

@Messages("computers.list.title", currentPage.getTotalCount)

- @request.flash.apply("success").map { successFlashValue => + @request.flash.asScala().get("success").map { successFlashValue =>
Done! @successFlashValue