Git Product home page Git Product logo

gradle-twirl's Introduction

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.

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:

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.

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.

gradle-twirl's People

Contributors

67726e avatar hhandoko avatar ivan-klass avatar valery1707 avatar nacmacfeegle avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.