<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[confest - Medium]]></title>
        <description><![CDATA[Another technical blog - Medium]]></description>
        <link>https://medium.com/confest?source=rss----82f4ea9a49ad---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>confest - Medium</title>
            <link>https://medium.com/confest?source=rss----82f4ea9a49ad---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 14:04:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/confest" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Writing a Play module]]></title>
            <link>https://medium.com/confest/writing-a-play-module-e8cc95cb9285?source=rss----82f4ea9a49ad---4</link>
            <guid isPermaLink="false">https://medium.com/p/e8cc95cb9285</guid>
            <category><![CDATA[play]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[modules]]></category>
            <dc:creator><![CDATA[prakash vadrevu]]></dc:creator>
            <pubDate>Fri, 25 Nov 2016 14:04:46 GMT</pubDate>
            <atom:updated>2018-02-16T23:19:04.264Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi there! In this post, I am going to explain you how to write “modules” in Play 2.5.</p><p>Since, Play 2.4, the framework started supporting Dependency Injection (DI) out of the box with “Google Guice”. For those of you who do not know what Guice is, it is a very simple and light weight framework for injecting dependencies into your classes. Its fun and easy to use and I personally like it very much.</p><p>Okay, lets get to the point, period.</p><p>The first thing is — “Play Plugins” have been deprecated in 2.5. Why? Because — since the Google Guice DI is supported out of the box, the “Modules” that we write can fully embrace this and hence, much easier management. So, practically, there is no need to have a Plugin model and manage them in our application.</p><h3>What are we going to do?</h3><p>We are going to write a simple module app, which just prints “Hello world from ConFest!”. Then, we are going to include it in our app. Thats it! Simple and to the point. Lets get started!</p><h3>Diving In!</h3><p>Lets start by creating a folder <strong>play-module-java-example</strong>. Now, use these:</p><ol><li>Hit command <strong>activator new</strong></li><li>Choose <strong>play-java</strong> from the options</li><li>Give your <strong>module name</strong></li><li>You are done!</li></ol><p>Here is how it goes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6b3dd167cc43194cbcb67ffbbf6c36f/href">https://medium.com/media/a6b3dd167cc43194cbcb67ffbbf6c36f/href</a></iframe><p>Awesome, we have got our basic structure ready. Wait, but this is for a regular Play! app not for a module. We need to alter this structure a bit to make it module-ready. Lets do it.</p><h3>Alterations</h3><ol><li>Delete the <strong>conf/routes.conf</strong>. Why? Because, when this module gets imported, it overrides the routes of the actual app.</li><li>Also, delete the <strong>conf/applications.conf</strong>. The configurations come from the actual app’s config file.</li><li>Wipe out the <strong>app</strong> folder completely. But keep the folder. We’ll add code soon in there.</li><li>For this module even the <strong>public</strong> folder is not required. Remove it too.</li></ol><p>At this point, your folder structure should look something like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d11359b916cc2f486d22df7a7be169cf/href">https://medium.com/media/d11359b916cc2f486d22df7a7be169cf/href</a></iframe><h3>Code</h3><p>Create your module’s package under <strong>app</strong>. I am creating it as <strong>in.confest.examplemodule</strong>. Now, we have to create our Guice Module to be included in the actual project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e841e7dcd46251739d486afef2cb1366/href">https://medium.com/media/e841e7dcd46251739d486afef2cb1366/href</a></iframe><p>Now, create the classes mentioned in the configure() method above. Pretty Simple classes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1bacff160a88355172d9823cdc7c56ea/href">https://medium.com/media/1bacff160a88355172d9823cdc7c56ea/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbe9f7d5a677387b9091e2230e8cb185/href">https://medium.com/media/fbe9f7d5a677387b9091e2230e8cb185/href</a></iframe><p>We are done with the coding part. Simple, isnt it?</p><h3>Configuration</h3><p>The coding part is done, but the piece to link it to the actual Play app is missing. We need to tell the world that a module called <strong>ExampleModule</strong> exists. For this, create <strong>conf/reference.conf</strong> file and include the following line in it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3c2a0d9cdbc51151e5ca5697b3595a7/href">https://medium.com/media/c3c2a0d9cdbc51151e5ca5697b3595a7/href</a></iframe><p>Now, lets configure the module’s properties like its name, version, etc… For this open your build.sbt and make sure it looks like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2cfc20c74a661ce43ba780e6421c06e/href">https://medium.com/media/e2cfc20c74a661ce43ba780e6421c06e/href</a></iframe><p>We are pretty much done! Lets get to building this now</p><h3>Build</h3><p>Use the command <strong>activator publish-local</strong> to build it. This is how your terminal output should look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/496db38837c8a60849e697c85911e899/href">https://medium.com/media/496db38837c8a60849e697c85911e899/href</a></iframe><p>Great job! we have built our module. Yay!</p><h3>Including module in app</h3><p>Now, its time to use this module. For this, you have to include this module as a dependency in your <strong>build.sbt</strong> file of the target app like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/519aff928d64498f4dbf7aaceb881c17/href">https://medium.com/media/519aff928d64498f4dbf7aaceb881c17/href</a></iframe><p>Now, you can use your new module in your app.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54cb86d06e5f444c9982c657b9f40e38/href">https://medium.com/media/54cb86d06e5f444c9982c657b9f40e38/href</a></iframe><p>Source code of this module has been hosted on <a href="https://github.com/prakashvadrevu/play-module-java-example">GitHub</a>.</p><p>Thats the end of the story folks. Stay tuned for more posts!</p><p>Please do leave your feed back below. Thank you.</p><p>HAPPY CODING…!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8cc95cb9285" width="1" height="1" alt=""><hr><p><a href="https://medium.com/confest/writing-a-play-module-e8cc95cb9285">Writing a Play module</a> was originally published in <a href="https://medium.com/confest">confest</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>