Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/67726e/gradle-twirl
A Gradle plugin for compiling Twirl templates.
https://github.com/67726e/gradle-twirl
Last synced: 3 months ago
JSON representation
A Gradle plugin for compiling Twirl templates.
- Host: GitHub
- URL: https://github.com/67726e/gradle-twirl
- Owner: 67726e
- License: mit
- Created: 2014-08-25T12:57:27.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-04T23:41:36.000Z (over 9 years ago)
- Last Synced: 2024-08-04T03:03:24.241Z (6 months ago)
- Language: Groovy
- Size: 164 KB
- Stars: 11
- Watchers: 4
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gradle - gradle-twirl - Provide [Twirl](https://github.com/playframework/twirl) template compilation and integration. (Plugins / Templating)
README
# Gradle Twirl Templates Plugin
A Gradle plugin to provide Twirl template compilation and integration for your projects.## Install
To use the Gradle plugin, just add the following to your `build.gradle` file.```groovy
buildscript {
repositories {
mavenCentral()
maven {
url "http://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath "us.hexcoder:gradle-twirl:1.0.0-SNAPSHOT"
}
}apply plugin: "twirl"
```If you are using the Twirl templates with Java, you will need to enable Scala's joint-compilation by assigning all Java
source directories to the Scala `sourceSet` and setting the Java `sourceSet` to be empty. Here is a default configuration:```groovy
apply plugin: "scala"sourceSets {
// See: http://forums.gradle.org/gradle/topics/how_to_compile_a_java_class_that_depends_on_a_scala_class_in_gradle
main {
scala {
srcDir "src/main/java"
}java {
srcDirs = []
}
}
}
```## Customization
The plugin should work out-of-the-box for most users. All you need are your source templates under `src/main/twirl` for
the templates to be picked up and compiled. If the defaults are not sufficient for you, you can use the plugin
configuration to tweak things to your liking.```groovy
twirl {
sourceDirectory = "src/main/twirl"
testSourceDirectory = "src/test/twirl"
targetDirectory = "build/generated-sources/main/twirl"
testTargetDirectory = "build/generated-sources/test/twirl"
imports = ["java.lang._", "java.util._", "scala.collection.JavaConversions._", "scala.collection.JavaConverters._"]
charset = "UTF8"
}
```## Tasks
The plugin makes two tasks available, `compileTwirl` and `compileTestTwirl`. These commands work in the same way that
commands like `compileJava` or `compileTestGroovy` would work. They compile from the source or test directories
respectively and output them into the appropriate directory. These tasks will be run before the `compileScala` or
`compileTestScala` tasks as available and as needed.