Table of contents
1.
Introduction
2.
Prerequisites
3.
Starting from the Source
4.
Documentation to Build in Play
5.
Running Tests
6.
Using Play in Projects
7.
Frequently Asked Questions
7.1.
What is the function of sbt?
7.2.
What is the purpose of the Play framework?
7.3.
Is Play an effective framework?
8.
Conclusion
Last Updated: Mar 27, 2024
Easy

Building Play from Source

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

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.

play logo

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

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:

$ git clone git://github.com/Playframework/Playframework.git

 

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).

starting from the source

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:

> +publishLocal

 

Alternatively, to publish for all Scala versions:

> ++ 2.13.8 publishLocal

 

Check out most important Git Interview Questions here.

Documentation to Build in Play

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:

$ cd Playframework/documentation
$ sbt run

 

To understand the guidelines for doc, you can refer to our blog Guidelines for Writing Play Documentation. Now, you’ll have the necessary doc to build in Play.

documentation to build in play

Running Tests

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.

If you think this blog has helped you with building play from source. And if you would like to learn more, check out our articles on Guidelines for writing play documentationAggregating Reverse RoutersCookbook, and Improving Compilation time. You can also refer to our guided path on the basics of java and many more on our Website.

Refer to our Guided Path on Coding Ninjas Studio. It will help you upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem Design, and many more! If you want to test your competency in coding, you may check out the mock test series. And participate in the contests hosted on Coding Ninjas Studio! 

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 problemsinterview experiences, and interview bundle for placement preparations.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Happy Learning!

Live masterclass