Gradle Play 2 plugin

Gradle plugin to build Play 2 projects.

License

License

Categories

Categories

Gradle Build Tools
GroupId

GroupId

com.github.ywelsch
ArtifactId

ArtifactId

gradle-play2-plugin
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Gradle Play 2 plugin
Gradle plugin to build Play 2 projects.
Project URL

Project URL

https://github.com/ywelsch/gradle-play2-plugin
Source Code Management

Source Code Management

https://github.com/ywelsch/gradle-play2-plugin

Download gradle-play2-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.ywelsch/gradle-play2-plugin/ -->
<dependency>
    <groupId>com.github.ywelsch</groupId>
    <artifactId>gradle-play2-plugin</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.ywelsch/gradle-play2-plugin/
implementation 'com.github.ywelsch:gradle-play2-plugin:0.1'
// https://jarcasting.com/artifacts/com.github.ywelsch/gradle-play2-plugin/
implementation ("com.github.ywelsch:gradle-play2-plugin:0.1")
'com.github.ywelsch:gradle-play2-plugin:jar:0.1'
<dependency org="com.github.ywelsch" name="gradle-play2-plugin" rev="0.1">
  <artifact name="gradle-play2-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.ywelsch', module='gradle-play2-plugin', version='0.1')
)
libraryDependencies += "com.github.ywelsch" % "gradle-play2-plugin" % "0.1"
[com.github.ywelsch/gradle-play2-plugin "0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

This plugin is OUTDATED: Gradle has built-in Play support nowadays.

gradle-play2-plugin

The gradle-play2-plugin enables the creation of Play 2 applications using Gradle.

Currently supported Play versions: [2.2.0 - 2.3.6]

Example Play 2 projects using the gradle plugin can be found in the samples directory

Scope

This gradle plugin provides the core functionality to develop Play 2 applications. It includes routes and template compiler, class enhancer for getters and setters and ebean, and a fully-configured lifecycle. It does not include, however, support for compiling LESS files, minifying JS files or other non-Play specific functionality. Examples of integrating other Gradle plugins for that goal can be found in the samples directory, for example the zentasks example.

Running examples

All examples from the Play 2 distribution are fully running.

Using the plugin

A typical usage of the plugin looks as follows:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.github.ywelsch:gradle-play2-plugin:+'
    }
}

apply plugin: 'com.github.ywelsch.play2-java'

play2 {
    version = '2.3.6'
    scalaVersion = '2.11'
}

As the plugin heavily relies on the Play 2 libraries, the Typesafe repository needs to be included:

repositories {
    mavenCentral()
    maven {
        url 'http://repo.typesafe.com/typesafe/releases'
    }
}

Java or Scala flavor

To configure the default lifecycle for building a Java Play 2 project, apply:

apply plugin: 'com.github.ywelsch.play2-java'

To configure the default lifecycle for building a Scala Play 2 project, apply:

apply plugin: 'com.github.ywelsch.play2-scala'

The default lifecycle includes support for packaging and running the Play 2 application. To that effect, it relies on the Gradle application plugin, providing the standard run, installApp, distZip tasks. The test framework is also pre-configured.

Configuration

play2 {
    // default configuration
    version = '2.3.6'
    scalaVersion = '2.11'
    appDir = new File('app')
    ebeanEnabled = false
    ebeanModels = 'models.*'
}

Tasks

The gradle-play2-plugin provides a number of tasks:

  • PlayCompileRoutes
  • PlayCompileTemplates
  • PlayEnhanceClasses

PlayCompileTemplates

task compilePlayTemplates(type: PlayCompileTemplates) {
    // default configuration
    templatesRootDir = play2.appDir
    templateImports = ["models._", "controllers._", ...] // List of imports
    templateFormats = ["html": "play.twirl.api.HtmlFormat", "txt": "play.twirl.api.TxtFormat", ...] // Map
    sourceEncoding = 'UTF-8'

    // Other more exotic configuration options
    playTemplatesClasspath = configurations.play2Templates
    useOldParser = false
    inclusiveDot = false
    oldCompiler = play2.version.startsWith('2.2.')

    // No default but pre-configured for standard task
    outputDir = file("$project.buildDir/generated-sources")
}

PlayCompileRoutes

task compilePlayRoutes(type: PlayCompileRoutes) {
    // default configuration
    additionalImports = ['play.libs.F', ...] // List of imports
    generateReverseRouter = true
    generateRefReverseRouter = true
    namespaceReverseRouter = false
    routesFile = file('conf/routes')

    // Other more exotic configuration options
    playRoutesClasspath = configurations.play2Routes
    oldCompiler = play2.version.startsWith('2.2.')

    // No default but pre-configured for standard task
    outputDir = file("$project.buildDir/generated-sources")
}

PlayEnhanceClasses

task playEnhanceClasses(type: PlayEnhanceClasses) {
    // default configuration
    ebeanEnabled = play2.ebeanEnabled
    ebeanModels = play2.ebeanModels
    outputDir = sourceSets.main.output.classesDir
    enhancementClasspath = file("$project.buildDir/classes/toBeEnhanced") // files to be enhanced
    classpath = configurations.compile + project.files(file("$project.buildDir/classes/toBeEnhanced"))

    // Other more exotic configuration options
    playEnhanceClassesClasspath = configurations.play2EnhanceClasses
    ebeanClasspath = configurations.ebean
}

For Plugin Developers

Integration tests are running the tests of all the provided samples. To test an example directly using the plugin sources, it can be run from the root project directory of the plugin as follows:

gradlew samples -Pdir=samples/playframework-2.3.6/samples/scala/zentasks -PgradleTasks=run

This calls the run task on the zentasks example.

Versions

Version
0.1