β-testing for Play Gradle Plugin #12338
Replies: 3 comments 9 replies
-
📣 New release Changelog:
|
Beta Was this translation helpful? Give feedback.
-
📣 New release Changelog:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback! Nevertheless I tried moving to pekko on the project I'm working on, and that was relatively painless. The biggest problem I'm seeing is given by the differences in how the new gradle plugin acts wrt to the old one. For instance, we were previously able to specify Jvm Args using the This, for instance, would be used to allow migrating to 2.9/3.0 - see here. I know we can run the task with the properties appended, just trying to hide that to service users. I will keep you posted if I find time to test this with Play 2.9.x 👍 Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hi, everyone! 👋
The Play Team is happy to announce the start of beta testing for our new Play Gradle Plugin (referred to as Play Plugin in the text below).
Current version:
3.0.2-773ecf9b-SNAPSHOT
(will be regularly updated here and we will also announce any further updates through additional comments below, so we recommend subscribing to this discussion thread to stay up to date)We highly value your feedback and encourage you to share your thoughts and experiences in the comments section of this discussion. Your input is essential for us to make improvements and enhancements.
We have tested the Play Plugin using all the examples in the
play-samples
repository (see play-samples#467). We encourage you to review how these projects are set up, you can use them as an example on how to migrate your projects to the new Play Plugin.Play version compatibility
Although you technically have the capability to use different versions of Play modules and the Play Plugin, we strongly recommend using the same version for both. Using mismatched versions may lead to compatibility issues and correctness is not guaranteed.
Gradle version compatibility
We haven't tested the Play Plugin with various Gradle versions (yet). Therefore, we currently recommend using the latest available version of Gradle. For instance, the examples mentioned above use Gradle 8.5. However, similar to the Twirl Gradle Plugin, we aim to support Gradle versions 7.1 and above in future releases of the Play Plugin.
Current status
All Play Plugin classes are annotated with
@Incubating
and may undergo changes in the future, depending on user feedback. Please keep this in mind.How to apply the Play Plugin
During the beta-testing period, the Play Plugin will be published in the OSS Sonatype repository. Therefore, to apply the Play Plugin to your project, you will need to follow these steps:
First, add the snapshot repository to your
settings.gradle[.kts]
file:Second, add the Play Plugin into your
build.gradle[.kts]
file:Features
Application Layout
The Play Plugin seamlessly supports both the Play and default Sbt/Gradle application layouts out of the box. No special settings are necessary. You can read more about these layouts in the Play documentation.
Twirl Integration
Of course, the Play Plugin works in synergy with the Twirl Plugin. It's important to note, however, that the Twirl Plugin must be applied before the Play Plugin in order to make additional settings. Additionally, we want to let you know that the Twirl Plugin is compatible with Gradle versions
7.1
and above.Dependency configurations
You can add dependencies to your application using standard Gradle Configurations. Additionally, we strongly recommend employing the Play BOM (Bill of Materials) for managing your dependency configurations.
Play Routes
The Play Plugin includes two tasks,
compilePlayRoutes
andcompileTestPlayRoutes
, which, as their names suggest, are, designed to compile routes. Both tasks are integrated into the standard Gradle build lifecycle, so you don't have to run them manually. Just be aware that they exist. These tasks also support multi-module projects and the "Aggregating reverse routers" feature.Below are a few related settings that you might find useful:
Web Assets
Similar to the Play Sbt plugin, all your assets will be packaged in a separate
*-assets.jar
file.Static Assets
The
processPublicAssets
task copies public static assets. This task, too, is integrated into the standard Gradle build lifecycle, so you don't need to run it manually. It's just good to be aware of its existence.Handling Compiled Assets
To manage compiled assets, you will need to either implement your own tasks or use third-party Gradle plugins, for example, the Gradle Node Plugin. We strongly recommend using third-party build systems like WebPack, Grunt, Gulp, which can be integrated into your Gradle build lifecycle.
The Play Plugin itself implements several things that you need to know about: Firstly, there is a special
SourceDirectorySet
namedassets
. It is important that all compiled assets end up in the directory referenced by thedestinationDirectory
property. Secondly, there is a specialprocessAssets
task, which, when executed, will process the assets. It's important that this task needs to depend on tasks implemented by you or on tasks provided by third-party Gradle plugins to function correctly.To give an example, consider that you want to use CoffeeScript in your project.
First, you will need to add a
package.json
file to your project:Then, add the CoffeeScript compilation task to your build script and ensure that the
processAssets
task depends on it:When the
processAssets
task is run, CoffeeScript files (*.coffee
) located in theapp/assets/javascripts/
folder will be compiled into JavaScript.js
files.Running the application
Running in development (DEV) mode
To run your app in development mode, use the
playRun
task. This task starts automatically in Gradle's continuous mode, tracks changes to the source code and hot-reloads the application as needed. Some settings of this task may be useful for you, for example:Running in production (PROD) mode
You can run your application in production mode using the standard Gradle
run
task. To do this, add a Play application secret to the task settings. For example:Running in production (PROD) (distribution)
Another way to run your application in production mode is by preparing a distribution using the standard Gradle
installDist
task. You can then run the application with the Play application secret as follows:Beta Was this translation helpful? Give feedback.
All reactions