Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
As a developer, it’s more interesting to create something rather than edit the existing work. If you want to do some unreleased changes, create something new for Play, or contribute to its development. You'll need to compile it from the source code.
This article will guide you through building Play from source. We will start from the source and check out the play source from the shell first. Afterward, we will go through the doc to build in Play and run tests. At the end of our discussion, we will be using Play in projects concluding our discussion of building play from source.
So let’s get started!
Prerequisites
Before starting our discussion on building Play from source. You must have sbt installed to build Play. sbt, like Apache's Maven and Ant, is an open-source build tool for Scala and Java projects. Its main characteristic is Scala code compilation. And its integration with many Scala test frameworks. Which is natively supported.
The continuous compilation, testing, and deployment are all possible in sbt. That’s why we will need sbt for our project.
Starting from the Source
We will start our discussion of building Play from source, by checking out the Play source from the shell first:
After we had done our git cloning. You should check out the branch you want. The main is the current development branch. While stable branches for major releases are named as a .x, such as 2.8.x (the latest Play branch).
Now execute sbt:
$ sbt
To create and publish Play, run publishLocal:
> publishLocal
This will create and publish Play for the standard Scala version. You can cross-build if you want to publish for all Scala versions:
The most important thing to know about building Play from source is in the doc. The doc is available as Markdown files at Playframework/documentation. Run the following to see HTML:
Without running tests, our mission of building Play from source is incomplete. There are two types of testing we will be doing in here, first is unit testing and the second is integration testing. You can use the test task to run unit and integration tests from the sbt console:
> test
As with publishing, you can prefix the command with + to run the tests against all Scala versions that are supported.
The Play PR validation includes scripted tests, testing the documentation code samples, and testing the Play templates in addition to the unit and integration tests. The PR validation scripts can be found in the framework/scripts directory; you can run each of these to run the same tests as the PR validation.
Using Play in Projects
Now, the most important part of building Play from source is using Play in projects. A snapshot version is added to your local repository when you publish Play locally.
You must update your build configuration to use this version to use it. To do so, make the following changes in project/plugins.sbt to your existing Play project:
// Change the sbt plugin to use the local Play build (2.8.0-SNAPSHOT)
addSbtPlugin("com.typesafe.Play" % "sbt-plugin" % "2.8.0-SNAPSHOT")
After that, you can launch the console and interact with your project as usual:
$ cd <projectdir>
$ sbt
Frequently Asked Questions
What is the function of sbt?
sbt is an open-source build tool for Scala and Java projects. It is similar to Ant and Apache's Maven. The compilation, testing, and deployment are done by sbt.
What is the purpose of the Play framework?
The Play Framework makes it simple to create web applications in Java and Scala. Play's architecture is lightweight, stateless, and web-friendly. The play is based on Akka. It provides predictable and low resource consumption applications.
Is Play an effective framework?
Play Framework is the best full-stack web framework. It is available today for developing Reactive Web Applications that use both the FP and RP paradigms.
Conclusion
In this article, we have extensively discussed building Play from source. We started our discussion starting from the source. Then we went through the documentation to build in Play and run tests. Afterward, we discussed using Play in projects. This concludes our discussion of building Play from source.
But suppose you have just started your learning process. And you are looking for questions from tech giants like Amazon, Microsoft, Uber, etc. In that case, you must look at the problems, interview experiences, and interview bundle for placement preparations.
Nevertheless, you may consider our paid courses to give your career an edge over others!