From 817376e73bb76858e529e46a425668a3b2b75f5b Mon Sep 17 00:00:00 2001 From: Dave O'Brien Date: Fri, 7 Dec 2018 14:46:48 +0000 Subject: [PATCH] Add sbt support --- .gitignore | 5 ++ .ruby-version | 1 + build.sbt | 18 +++++++ conf/application.conf | 99 +++++++++++++++++++++++++++++++++++ conf/prod.routes | 2 + project/AppDependencies.scala | 15 ++++++ project/build.properties | 1 + project/plugins.sbt | 9 ++++ test/BuildSpec.scala | 30 +++++++++++ 9 files changed, 180 insertions(+) create mode 100644 .ruby-version create mode 100644 build.sbt create mode 100644 conf/application.conf create mode 100644 conf/prod.routes create mode 100644 project/AppDependencies.scala create mode 100644 project/build.properties create mode 100644 project/plugins.sbt create mode 100644 test/BuildSpec.scala diff --git a/.gitignore b/.gitignore index 6a57082..9fd76bb 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,8 @@ Staticfile.auth /vendor +/public +/target +/project/project +/project/target +/.project \ No newline at end of file diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..73462a5 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.5.1 diff --git a/build.sbt b/build.sbt new file mode 100644 index 0000000..bff9588 --- /dev/null +++ b/build.sbt @@ -0,0 +1,18 @@ +import uk.gov.hmrc.sbtdistributables.SbtDistributablesPlugin.publishingSettings + +val appName = "vat-end-to-end" + +lazy val microservice = Project(appName, file(".")) + .enablePlugins(play.sbt.PlayScala, SbtAutoBuildPlugin, SbtGitVersioning, SbtDistributablesPlugin, SbtArtifactory) + .settings( + libraryDependencies ++= AppDependencies.compile ++ AppDependencies.test, + evictionWarningOptions in update := EvictionWarningOptions.default.withWarnScalaVersionEviction(false), + majorVersion := 0 + ) + .settings( + publishingSettings: _* + ) + .settings( + resolvers += Resolver.bintrayRepo("hmrc", "releases"), + resolvers += Resolver.jcenterRepo + ) diff --git a/conf/application.conf b/conf/application.conf new file mode 100644 index 0000000..8e1e7ac --- /dev/null +++ b/conf/application.conf @@ -0,0 +1,99 @@ +# Copyright 2018 HM Revenue & Customs +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include "backend.conf" + +# This is the main configuration file for the application. +# ~~~~~ + +appName=vat-service-guide +appUrl="http://"${appName}".local" +incapacityBenefitPAYEReference="892/BA500" +employmentAndSupportAllowancePAYEReference="267/ESA500" + +# An ApplicationLoader that uses Guice to bootstrap the application. +play.application.loader = "uk.gov.hmrc.play.bootstrap.ApplicationLoader" + +# Primary entry point for all HTTP requests on Play applications +#play.http.requestHandler = "uk.gov.hmrc.play.bootstrap.http.RequestHandler" + +# Provides an implementation of AuditConnector. Use `uk.gov.hmrc.play.bootstrap.AuditModule` or create your own. +# An audit connector must be provided. +#play.modules.enabled += "uk.gov.hmrc.play.bootstrap.AuditModule" + +# Provides an implementation of MetricsFilter. Use `uk.gov.hmrc.play.graphite.GraphiteMetricsModule` or create your own. +# A metric filter must be provided +#play.modules.enabled += "uk.gov.hmrc.play.bootstrap.graphite.GraphiteMetricsModule" + +# Play Modules +# ~~~~ +# Additional play modules can be added here + +# Session Timeout +# ~~~~ +# The default session timeout for the app is 15 minutes (900seconds). +# Updating this is the responsibility of the app - it must issue a new cookie with each request or the session will +# timeout 15 minutes after login (regardless of user activity). +# session.maxAge=900 + +# Secret key +# ~~~~~ +# The secret key is used to secure cryptographics functions. +# If you deploy your application to several instances be sure to use the same key! +play.crypto.secret="DUMMY" + +# Session configuration +# ~~~~~ +application.session.httpOnly=false +application.session.secure=false + +# The application languages +# ~~~~~ +application.langs="en" + +# Router +# ~~~~~ +# Define the Router object to use for this application. +# This router will be looked up first when the application is starting up, +# so make sure this is the entry point. +# Furthermore, it's assumed your route file is named properly. +# So for an application router like `my.application.Router`, +# you may need to define a router file `conf/my.application.routes`. +# Default to Routes in the root package (and conf/routes) +# !!!WARNING!!! DO NOT CHANGE THIS ROUTER +play.http.router=prod.Routes + +# Metrics plugin settings - graphite reporting is configured on a per env basis +metrics { + name = ${appName} + rateUnit = SECONDS + durationUnit = SECONDS + showSamples = true + jvm = true + enabled = true +} + + +# Microservice specific config + +auditing { + enabled=false + traceRequests=true + consumer { + baseUri { + host = localhost + port = 8100 + } + } +} diff --git a/conf/prod.routes b/conf/prod.routes new file mode 100644 index 0000000..1e39cc9 --- /dev/null +++ b/conf/prod.routes @@ -0,0 +1,2 @@ +GET / controllers.Assets.at(path="/public", file="index.html") +GET /*file controllers.Assets.at(path="/public", file) diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala new file mode 100644 index 0000000..e9dada9 --- /dev/null +++ b/project/AppDependencies.scala @@ -0,0 +1,15 @@ +import play.core.PlayVersion +import play.sbt.PlayImport._ +import sbt._ + +object AppDependencies { + val bootStrapPlayVersion = "3.14.0" + + val compile = Seq( + ws, + "uk.gov.hmrc" %% "bootstrap-play-25" % bootStrapPlayVersion) + + val test = Seq( + "org.pegdown" % "pegdown" % "1.6.0" % "test", + "org.scalatest" %% "scalatest" % "3.0.5" % "test") +} diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 0000000..133a8f1 --- /dev/null +++ b/project/build.properties @@ -0,0 +1 @@ +sbt.version=0.13.17 diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 0000000..798b9ef --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,9 @@ +resolvers += Resolver.url("hmrc-sbt-plugin-releases", url("https://dl.bintray.com/hmrc/sbt-plugin-releases"))(Resolver.ivyStylePatterns) +resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/" +resolvers += "HMRC Releases" at "https://dl.bintray.com/hmrc/releases" + +addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.13.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "1.15.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-artifactory" % "0.14.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "1.2.0") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.12") diff --git a/test/BuildSpec.scala b/test/BuildSpec.scala new file mode 100644 index 0000000..6b01eaa --- /dev/null +++ b/test/BuildSpec.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2018 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package test + +import org.scalatest.{Matchers, WordSpec} +import sys.process._ + +class BuildSpec extends WordSpec with Matchers { + "Building the content" should { + "produce static files" in { + val result = "bundle install" #&& "bundle exec middleman build --build-dir=public/" ! + + result shouldBe 0 + } + } +}