Full Code of townsfolk/gradle-templates for AI

master d1df399ec74b cached
87 files
130.8 KB
33.4k tokens
1 requests
Download .txt
Repository: townsfolk/gradle-templates
Branch: master
Commit: d1df399ec74b
Files: 87
Total size: 130.8 KB

Directory structure:
gitextract_7j9h8z64/

├── .gitignore
├── LICENSE.txt
├── README.md
├── build.gradle
├── gradle.properties
├── installation/
│   ├── apply-local.groovy
│   └── apply.groovy
├── pom.xml
├── release.gradle
└── src/
    ├── main/
    │   ├── groovy/
    │   │   └── templates/
    │   │       ├── GradlePluginTemplatesPlugin.groovy
    │   │       ├── GroovyTemplatesPlugin.groovy
    │   │       ├── JavaTemplatesPlugin.groovy
    │   │       ├── ProjectTemplate.groovy
    │   │       ├── ScalaTemplatesPlugin.groovy
    │   │       ├── TemplatesPlugin.groovy
    │   │       ├── TemplatesPluginConvention.groovy
    │   │       ├── WebappTemplatesPlugin.groovy
    │   │       └── tasks/
    │   │           ├── AbstractProjectTask.groovy
    │   │           ├── AbstractTemplateExportTask.groovy
    │   │           ├── gradle/
    │   │           │   ├── AbstractGradleProjectTask.groovy
    │   │           │   ├── CreateGradlePluginTask.groovy
    │   │           │   ├── ExportPluginTemplatesTask.groovy
    │   │           │   └── InitGradlePluginTask.groovy
    │   │           ├── groovy/
    │   │           │   ├── AbstractGroovyProjectTask.groovy
    │   │           │   ├── CreateGroovyClassTask.groovy
    │   │           │   ├── CreateGroovyProjectTask.groovy
    │   │           │   ├── ExportGroovyTemplatesTask.groovy
    │   │           │   └── InitGroovyProjectTask.groovy
    │   │           ├── java/
    │   │           │   ├── AbstractJavaProjectTask.groovy
    │   │           │   ├── CreateJavaClassTask.groovy
    │   │           │   ├── CreateJavaProjectTask.groovy
    │   │           │   ├── ExportJavaTemplatesTask.groovy
    │   │           │   └── InitJavaProjectTask.groovy
    │   │           ├── scala/
    │   │           │   ├── AbstractScalaProjectTask.groovy
    │   │           │   ├── CreateScalaClassTask.groovy
    │   │           │   ├── CreateScalaObjectTask.groovy
    │   │           │   ├── CreateScalaProjectTask.groovy
    │   │           │   ├── ExportScalaTemplatesTask.groovy
    │   │           │   └── InitScalaProjectTask.groovy
    │   │           └── webapp/
    │   │               ├── AbstractWebappProjectTask.groovy
    │   │               ├── CreateWebappProjectTask.groovy
    │   │               ├── ExportWebappTemplatesTask.groovy
    │   │               └── InitWebappProjectTask.groovy
    │   └── resources/
    │       ├── META-INF/
    │       │   └── gradle-plugins/
    │       │       ├── gradle-plugin-templates.properties
    │       │       ├── groovy-templates.properties
    │       │       ├── java-templates.properties
    │       │       ├── scala-templates.properties
    │       │       ├── templates.properties
    │       │       └── webapp-templates.properties
    │       └── templates/
    │           ├── groovy/
    │           │   ├── build.gradle.tmpl
    │           │   └── groovy-class.tmpl
    │           ├── java/
    │           │   ├── build.gradle.tmpl
    │           │   └── java-class.tmpl
    │           ├── plugin/
    │           │   ├── build.gradle.tmpl
    │           │   ├── convention-class.tmpl
    │           │   └── plugin-class.tmpl
    │           ├── scala/
    │           │   ├── build.gradle.tmpl
    │           │   └── scala-class.tmpl
    │           └── webapp/
    │               ├── build.gradle.tmpl
    │               └── web-xml.tmpl
    └── test/
        └── groovy/
            └── templates/
                ├── AbstractTaskTester.groovy
                ├── GradlePluginTemplatesPluginTest.groovy
                ├── GroovyTemplatesPluginTest.groovy
                ├── JavaTemplatesPluginTest.groovy
                ├── ProjectTemplateTest.groovy
                ├── ScalaTemplatesPluginTest.groovy
                ├── TemplatesPluginTest.groovy
                ├── WebappTemplatesPluginTest.groovy
                └── tasks/
                    ├── gradle/
                    │   ├── CreateGradlePluginTaskTest.groovy
                    │   ├── ExportPluginTemplatesTaskTest.groovy
                    │   └── InitGradlePluginTaskTest.groovy
                    ├── groovy/
                    │   ├── CreateGroovyClassTaskTest.groovy
                    │   ├── CreateGroovyProjectTaskTest.groovy
                    │   ├── ExportGroovyTemplatesTaskTest.groovy
                    │   └── InitGroovyProjectTaskTest.groovy
                    ├── java/
                    │   ├── CreateJavaClassTaskTest.groovy
                    │   ├── CreateJavaProjectTaskTest.groovy
                    │   ├── ExportJavaTemplatesTaskTest.groovy
                    │   └── InitJavaProjectTaskTest.groovy
                    ├── scala/
                    │   ├── CreateScalaClassTaskTest.groovy
                    │   ├── CreateScalaObjectTaskTest.groovy
                    │   ├── CreateScalaProjectTaskTest.groovy
                    │   ├── ExportScalaTemplatesTaskTest.groovy
                    │   └── InitScalaProjectTaskTest.groovy
                    └── webapp/
                        ├── CreateWebappProjectTaskTest.groovy
                        ├── ExportWebappTemplatesTaskTest.groovy
                        └── InitWebappProjectTaskTest.groovy

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
build
.gradle
*.iml
*.ipr
*.iws
.classpath
.project
.settings
.idea
out
classes

================================================
FILE: LICENSE.txt
================================================


                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================
# Gradle Templates Plugin

## Introduction

The Gradle Templates plugin helps you get started using Gradle by providing convenient tasks for creating new projects that work with the Gradle build system.
Eg. To create a new Java project you can run:

```gradle createJavaProject```

Which will prompt you for the name of your new project and then create a new directory with it. It will also create a standard directory structure in your
project's directory that works with Gradle's default configurations.

The plugin also makes it easy to create your own templates which can be useful in creating new projects, or creating components within your projects. Eg.
It's easy to create a simple task to generate a new GSP that fits your company's standard layout. Or to create a more complex task to generate a new servlet
and add the entry into your webapp's web.xml file.

## Installation

The standard way to install this plugin is by adding the following to your build.gradle file:

```groovy
buildscript {
    repositories {
        maven {
			url 'http://dl.bintray.com/cjstehno/public'
		}
    }
    dependencies {
        classpath 'gradle-templates:gradle-templates:1.5'
    }
}

apply plugin:'templates'
```

Other methods of installation are documented on the project [installation](https://github.com/townsfolk/gradle-templates/wiki/Installation) page.

## Usage

Run the `gradle tasks` command to see a list of "create", "init", and "export" tasks provided by the default plugin templates.

Running a create or init task will prompt the user for information and then generate the appropriate content.

The main difference between the `create*Project` and `init*Project` tasks is that the create tasks end up creating a new directory
for your new project, and the init tasks will create the default directory structure under the current directory.

The `export*` tasks cause the templates to be exported to the local project.

Other usage documentation can be found on the project [Usage](https://github.com/townsfolk/gradle-templates/wiki/Usage) page.

## Details

* Version: 1.5
* Project Site: [http://cjstehno.github.io/gradle-templates](http://cjstehno.github.io/gradle-templates)
* Project Repo: [https://github.com/townsfolk/gradle-templates](https://github.com/townsfolk/gradle-templates)
* Wiki/Documentation: [https://github.com/townsfolk/gradle-templates/wiki](https://github.com/townsfolk/gradle-templates/wiki)
* License: [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.html)
* Questions, bugs, issues: [https://github.com/townsfolk/gradle-templates/issues](https://github.com/townsfolk/gradle-templates/issues)

[![Build Status](https://drone.io/github.com/cjstehno/gradle-templates/status.png)](https://drone.io/github.com/cjstehno/gradle-templates/latest)



================================================
FILE: build.gradle
================================================
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'

repositories { mavenCentral() }

dependencies {
	compile gradleApi()
	compile localGroovy()

    testCompile 'junit:junit:4.11'
}


================================================
FILE: gradle.properties
================================================
group=gradle-templates
version=1.5


================================================
FILE: installation/apply-local.groovy
================================================
buildscript {
	repositories {
		ivy {
		   String tpInstallDir = project.hasProperty('gradle.templates.dir') ? project.getProperty('gradle.templates.dir') :
				                                                         System.properties['user.dir']
			name = 'gradle_templates'
			artifactPattern "${tpInstallDir}/build/libs/[artifact]-[revision].jar"
		}
	}
	dependencies {
		def templatesVersion = project.hasProperty('gradle.templates.ver') ? project.getProperty('gradle.templates.ver') :
                                                                         project.version
		classpath "gradle-templates:gradle-templates:${templatesVersion}"
	}
}
// Check to make sure templates.TemplatesPlugin isn't already added.
if (!project.plugins.findPlugin(templates.TemplatesPlugin)) {
	project.apply(plugin: templates.TemplatesPlugin)
}

================================================
FILE: installation/apply.groovy
================================================

buildscript {
    repositories {
        maven {
            url 'http://dl.bintray.com/cjstehno/public'
        }
    }
    dependencies {
        classpath 'gradle-templates:gradle-templates:1.5'
    }
}

// Check to make sure templates.TemplatesPlugin isn't already added.
if (!project.plugins.findPlugin(templates.TemplatesPlugin)) {
	project.apply(plugin: templates.TemplatesPlugin)
}

================================================
FILE: pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
  ~ Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>gradle-templates</groupId>
    <artifactId>gradle-templates</artifactId>
    <version>1.5</version>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>


================================================
FILE: release.gradle
================================================
apply plugin: 'groovy'
apply from: 'https://launchpad.net/gradle-release/trunk/latest/+download/apply.groovy'

configurations {
	installers {}
}

repositories {
	mavenCentral()
}

dependencies {
	compile gradleApi()
	groovy localGroovy()
}

// This updates the apply script with the new version.
updateVersion << {
	def applyFile = new File("installation", "apply.groovy")
	def oldVersion = project.getProperty("release.oldVersion")
	def newVersion = project.getProperty("release.newVersion")
	ant.replace(file: applyFile, token: "${group}:${name}:${oldVersion}", value: "${group}:${name}:${newVersion}")
	ant.replaceregexp(file: readmeFile, match: "Current Version: .*?\$", replace: "Current Version: ${oldVersion}", byline: true)
	ant.replaceregexp(file: readmeFile, match: "gradle-templates/\\d+\\.\\d+/apply.groovy", replace: "gradle-templates/${oldVersion}/apply.groovy", byline: true)
}

artifacts {
	archives jar
	installers file('installation/apply.groovy')
}

uploadArchives {
	repositories {
		add(new org.apache.ivy.plugins.resolver.SFTPResolver()) {
			host = releaseRepoHost
			addIvyPattern "${releaseRepoBase}/[module]/[revision]/[artifact]-[revision].[ext]"
			addArtifactPattern "${releaseRepoBase}/[module]/[revision]/[artifact]-[revision].[ext]"
		}
	}
}

uploadInstallers {
	repositories {
		add(new org.apache.ivy.plugins.resolver.SFTPResolver()) {
			host = releaseRepoHost
			addArtifactPattern "${releaseRepoBase}/[module]/[revision]/[artifact].[ext]"
		}
		add(new org.apache.ivy.plugins.resolver.SFTPResolver()) {
			host = releaseRepoHost
			addArtifactPattern "${releaseRepoBase}/[module]/[artifact].[ext]"
		}
	}
}

createReleaseTag.dependsOn uploadArchives
createReleaseTag.dependsOn uploadInstallers

================================================
FILE: src/main/groovy/templates/GradlePluginTemplatesPlugin.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates

import org.gradle.api.Project
import templates.tasks.gradle.CreateGradlePluginTask
import templates.tasks.gradle.ExportPluginTemplatesTask
import templates.tasks.gradle.InitGradlePluginTask

/**
 * Adds basic tasks for bootstrapping gradle plugin projects. Adds createGradlePlugin, exportPluginTemplates, and
 * initGradlePlugin tasks. Also applies the groovy-templates plugin.
 */
class GradlePluginTemplatesPlugin extends GroovyTemplatesPlugin {

	void apply(Project project) {
		// Check to make sure GroovyTemplatesPlugin isn't already added.
		if (!project.plugins.findPlugin(GroovyTemplatesPlugin)) {
			project.apply(plugin: GroovyTemplatesPlugin)
		}

		project.task 'createGradlePlugin', type:CreateGradlePluginTask

		project.task 'exportPluginTemplates', type:ExportPluginTemplatesTask

		project.task 'initGradlePlugin', type:InitGradlePluginTask
	}
}

================================================
FILE: src/main/groovy/templates/GroovyTemplatesPlugin.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates

import org.gradle.api.Plugin
import org.gradle.api.Project
import templates.tasks.groovy.CreateGroovyClassTask
import templates.tasks.groovy.CreateGroovyProjectTask
import templates.tasks.groovy.ExportGroovyTemplatesTask
import templates.tasks.groovy.InitGroovyProjectTask

/**
 * Adds basic tasks for bootstrapping Groovy projects. Adds createGroovyClass, createGroovyProject,
 * exportGroovyTemplates, and initGroovyProject tasks.
 */
class GroovyTemplatesPlugin implements Plugin<Project> {

	void apply(Project project) {
		project.task 'createGroovyClass',   type:CreateGroovyClassTask
        project.task 'createGroovyProject', type:CreateGroovyProjectTask

		project.task 'exportGroovyTemplates', type:ExportGroovyTemplatesTask

		project.task 'initGroovyProject', type:InitGroovyProjectTask
	}
}

================================================
FILE: src/main/groovy/templates/JavaTemplatesPlugin.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates

import org.gradle.api.Plugin
import org.gradle.api.Project
import templates.tasks.java.CreateJavaClassTask
import templates.tasks.java.CreateJavaProjectTask
import templates.tasks.java.ExportJavaTemplatesTask
import templates.tasks.java.InitJavaProjectTask

/**
 * Adds basic tasks for bootstrapping Java projects. Adds createJavaClass, createJavaProject,
 * exportJavaTemplates, and initJavaProject tasks.
 */
class JavaTemplatesPlugin implements Plugin<Project> {

	/**
	 * Pulls a fully qualified class name into it's parts - package, and name.
     *
	 * @param fullClassName
	 * @return Map containing the class name, package, and package as a path.
	 */
	static getClassParts( final String fullClassName ){
		def classParts = fullClassName.split(/\./) as List
		[
				className: classParts.pop(),
				classPackagePath: classParts.join(File.separator),
				classPackage: classParts.join('.')
		]
	}

	void apply(Project project) {
		project.task 'createJavaClass',   type:CreateJavaClassTask
		project.task 'createJavaProject', type:CreateJavaProjectTask

        project.task 'exportJavaTemplates', type:ExportJavaTemplatesTask

        project.task 'initJavaProject', type:InitJavaProjectTask
	}
}

================================================
FILE: src/main/groovy/templates/ProjectTemplate.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates

import groovy.text.GStringTemplateEngine

/**
 * This class is used to construct a ProjectTemplate. A project template consists of files and directories. This builder
 * can be used to set up the necessary files and directories needed for new projects.
 *
 * Eg.
 * <pre>
 * ProjectTemplate.fromUserDir {
 *    directory('src') { // creates new directory named 'src'
 *       dir('main') { // creates a new directory named 'main'
 *          d('java') { // creates a new directory named 'java'
 *             file('Class1.java') // creates a new file named 'Class1.java'
 *             f('Class2.java') // creates a new file named 'Class2.java'
 *          }
 *       }
 *    }
 * }
 * </pre>
 *
 * Can also be used without method calls for directory and file.
 * Eg.
 * <pre>
 * ProjectTemplate.fromUserDir {
 *    'src/main' { // creates the directories 'src', and 'main'.
 *       'java' {
 *          'Class1.java' 'public class Class1 {}' // creates the file 'Class1.java' with some initial content.
 *       }
 *       'resources' {}
 *    }
 * }
 * </pre>
 *
 * @author: elberry
 * Date: 4/9/11 6:04 PM
 */
class ProjectTemplate {

	private File parent

	/**
	 * Private so that it can't be accessed. Use one of the static 'fromUserDir' methods to start building a template.
	 */
	private ProjectTemplate() {}

	/**
	 * Same as the directory method.
	 * @param name
	 * @param closure
	 * @see #directory(String, Closure)
	 */
	void d(String name, Closure closure = {}) {
		directory(name, closure)
	}

	/**
	 * Same as the directory method.
	 * @param name
	 * @param closure
	 * @see #directory(String, Closure)
	 */
	void dir(String name, Closure closure = {}) {
		directory(name, closure)
	}

	/**
	 * Creates a directory, and it's parents if they don't already exist.
	 * @param name
	 * @param closure
	 * @see #directory(String, Closure)
	 */
	void directory(String name, Closure closure = {}) {
		File oldParent = parent
		if (parent) {
			parent = new File(parent, name)
		} else {
			parent = new File(name)
		}
		parent.mkdirs()
		closure.delegate = this
		closure()
		parent = oldParent
	}

	/**
	 * Same as file method
	 * @param args
	 * @param name
	 * @see #file(Map, String)
	 */
	void f(Map args = [:], String name) {
		file(args, name)
	}

	/**
	 * Same as file method
	 * @param args
	 * @param name
	 * @see #file(String, String)
	 */
	void f(String name, String content) {
		file(name, content)
	}

	/**
	 * Creates a new file with the given name. If a 'content' argument is provided it will be appended, or replace the
	 * content of the current file (if it exists) based on the value of the 'append' argument.
	 * @param args Arguments to be used when creating the new file: [content: String, append: boolean]
	 * @param name Name of the new file to be created.
	 */
	void file(Map args = [:], String name) {
		File file
		if (parent) {
			file = new File(parent, name)
		} else {
			file = new File(name)
		}
		file.exists() ?: file.parentFile.mkdirs() && file.createNewFile()
		def content
		if (args.content) {
			content = args.content.stripIndent()
		} else if (args.template) {
			content = renderTemplate(args, args.template)
		}
		if (content) {
			if (args.append) {
				file.append(content)
			} else {
				file.text = content
			}
		}
	}

    /**
     * Render the template at the given path with the provided parameters. An attempt will be made to load the template path
     * as an absolute path, then as a relative path, then lastly from the classpath.
     *
     * @param params
     * @param template the template path
     * @return the rendered template
     */
	String renderTemplate(Map params = [:], String template) {
		def tLoc = new File(template)
		if (!tLoc.exists()) { // check given path
			// Couldn't find file at given path, trying relative path.
			def rTemplate = template
			if (rTemplate.startsWith('/')) {
				rTemplate = rTemplate - '/'
			}
			tLoc = new File(System.getProperty('user.dir'), rTemplate)
			if (!tLoc.exists()) { // check relative path from current working dir.
				tLoc = getClass().getResource(template) // last ditch, use classpath.
			}
		}
		def tReader = tLoc?.newReader()
		if (tReader) {
			return new GStringTemplateEngine().createTemplate(tReader)?.make(params)?.toString()
		}
		throw new RuntimeException("Could not locate template: ${template}")
	}

	/**
	 * Calls file([content: content], name)
	 * @param name
	 * @param content
	 * @see #file(Map, String)
	 */
	void file(String name, String content) {
		file([content: content], name)
	}

	/**
	 * Starts the ProjectTemplate in the "user.dir" directory, unless the init.dir system property is specified.
	 * @param closure
	 */
	static void fromUserDir(Closure closure = {}) {
		new ProjectTemplate().directory(System.getProperty( 'init.dir', System.getProperty('user.dir') ), closure)
	}

	/**
	 * Starts the ProjectTemplate in the given path.
	 * @param path String path to the root of the new project.
	 * @param closure
	 */
	static void fromRoot(String path, Closure closure = {}) {
		new ProjectTemplate().directory(path, closure)
	}

	/**
	 * Starts the ProjectTemplate in the given file path.
	 * @param pathFile File path to the root of the new project.
	 * @param closure
	 */
	static void fromRoot(File pathFile, Closure closure = {}) {
		new ProjectTemplate().directory(pathFile.path, closure)
	}

	/**
	 * Handles creation of files or directories without the need to specify directly.
	 * @param name
	 * @param args
	 * @return
	 */
	def methodMissing(String name, def args) {
		if (args) {
			def arg = args[0]
			if (arg instanceof Closure) {
				directory(name, arg)
			} else if (arg instanceof Map) {
				file(arg, name)
			} else if (arg instanceof String || arg instanceof GString) {
				file([content: arg], name)
			} else {
				println "Couldn't figure out what to do. name: ${name}, arg: ${arg}, type: ${arg.getClass()}"
			}
		}
	}
}

================================================
FILE: src/main/groovy/templates/ScalaTemplatesPlugin.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates

import org.gradle.api.Plugin
import org.gradle.api.Project
import templates.tasks.scala.CreateScalaClassTask
import templates.tasks.scala.CreateScalaObjectTask
import templates.tasks.scala.CreateScalaProjectTask
import templates.tasks.scala.ExportScalaTemplatesTask
import templates.tasks.scala.InitScalaProjectTask

/**
 * Adds basic tasks for bootstrapping Scala projects.
 *
 * Adds createScalaClass, createScalaObject, createScalaProject, exportScalaTemplates, and initScalaProject tasks.
 */
class ScalaTemplatesPlugin implements Plugin<Project> {
    // TODO: is this plugin really needed or just roll into main?

    void apply(Project project) {
		project.task 'createScalaClass',   type:CreateScalaClassTask
		project.task 'createScalaObject',  type:CreateScalaObjectTask
        project.task 'createScalaProject', type:CreateScalaProjectTask

        project.task 'exportScalaTemplates', type:ExportScalaTemplatesTask

        project.task 'initScalaProject', type:InitScalaProjectTask
    }
}



================================================
FILE: src/main/groovy/templates/TemplatesPlugin.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package templates

import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project

/**
 * The core of the templates plugin.
 */
class TemplatesPlugin implements Plugin<Project> {

	static final String group = 'Template'
	static final String lineSep = System.getProperty( 'line.separator' )
	static final String inputPrompt = "${lineSep}templates>"

	static void prependPlugin(String plugin, File gradleFile) {
		def oldText = gradleFile.text
		gradleFile.text = ''
		gradleFile.withPrintWriter { pw ->
			pw.println "apply plugin: '${plugin}'"
			pw.print oldText
		}
	}

	static String prompt(String message, String defaultValue = null) {
		readLine(message, defaultValue)
	}

	static int promptOptions(String message, List options = []) {
		promptOptions(message, 0, options)
	}

	static int promptOptions(String message, int defaultValue, List options = []) {
		String consoleMessage = "${message}"
		consoleMessage += "${lineSep}    Pick an option ${1..options.size()}"
		options.eachWithIndex { option, index ->
			consoleMessage += "${lineSep}     (${index + 1}): ${option}"
		}
		try {
			def range = 0..options.size() - 1
			int choice = Integer.parseInt(readLine(consoleMessage, defaultValue))
			if (choice == 0) {
				throw new GradleException('No option provided')
			}
			choice--
			if (range.containsWithinBounds(choice)) {
				return choice
			} else {
				throw new IllegalArgumentException('Option is not valid.')
			}
		} catch (NumberFormatException e) {
			throw new IllegalArgumentException('Option is not valid.', e)
		}
	}

	static boolean promptYesOrNo( final String message, final boolean defaultValue = false) {
		String consoleVal = readLine("$message (Y|n)", defaultValue ? 'Y' : 'n')
        return consoleVal?.toLowerCase()?.startsWith('y') ?: defaultValue
	}

	private static String readLine(String message, def defaultValue = null) {
		String _message = "$inputPrompt $message " + (defaultValue ? "$lineSep [$defaultValue] " : "")
		if (System.console()) {
			return System.console().readLine(_message) ?: String.valueOf(defaultValue)
		}
		println "$_message (WAITING FOR INPUT BELOW)"
		return System.in.newReader().readLine() ?: String.valueOf(defaultValue)
	}

	def void apply(Project project) {
		project.convention.plugins.templatePlugin = new TemplatesPluginConvention()

        // FIXME: would be better to allow user to configure the desired template set rather than get them all
		project.apply(plugin: GroovyTemplatesPlugin)
		project.apply(plugin: GradlePluginTemplatesPlugin)
		project.apply(plugin: JavaTemplatesPlugin)
		project.apply(plugin: ScalaTemplatesPlugin)
		project.apply(plugin: WebappTemplatesPlugin)

		project.task(
            'exportAllTemplates',
            dependsOn: [
				'exportJavaTemplates', 'exportGroovyTemplates', 'exportScalaTemplates', 'exportWebappTemplates', 'exportPluginTemplates'
            ],
            group: TemplatesPlugin.group,
            description: 'Exports all the default template files into the current directory.'
        ) {}
	}
}


================================================
FILE: src/main/groovy/templates/TemplatesPluginConvention.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates

/**
 * @author: elberry
 * Date: 4/12/11 12:27 AM
 */
class TemplatesPluginConvention {
	String gradlePluginApplyLabel
	String gradlePluginClassName
	String sourceBasePackage

	def templates(Closure closure) {
		closure.delegate = this
		closure()
	}
}


================================================
FILE: src/main/groovy/templates/WebappTemplatesPlugin.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates

import org.gradle.api.Plugin
import org.gradle.api.Project
import templates.tasks.webapp.CreateWebappProjectTask
import templates.tasks.webapp.ExportWebappTemplatesTask
import templates.tasks.webapp.InitWebappProjectTask

/**
 * Adds basic tasks for bootstrapping Webapp projects. Adds createWebappProject, exportWebappTemplates, and
 * initWebappProject tasks. Also applies the java-templates plugin.
 */
class WebappTemplatesPlugin extends JavaTemplatesPlugin implements Plugin<Project> {

	void apply(Project project) {
		// Check to make sure JavaTemplatesPlugin isn't already added.
		if (!project.plugins.findPlugin(JavaTemplatesPlugin)) {
			project.apply(plugin: JavaTemplatesPlugin)
		}

		project.task 'createWebappProject', type:CreateWebappProjectTask

		project.task 'exportWebappTemplates', type:ExportWebappTemplatesTask

		project.task 'initWebappProject', type:InitWebappProjectTask
	}
}

================================================
FILE: src/main/groovy/templates/tasks/AbstractProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks

import org.gradle.api.DefaultTask
import templates.TemplatesPlugin

/**
 * Abstract base class for project tasks.
 */
abstract class AbstractProjectTask extends DefaultTask {

    static final String NEW_PROJECT_NAME = 'newProjectName'
    static final String PROJECT_GROUP = 'projectGroup'
    static final String PROJECT_VERSION = 'projectVersion'
    static final String PROJECT_PARENT_DIR = 'projectParentDir'

    AbstractProjectTask( final String name, final String description ){
        this.name = name
        this.group = TemplatesPlugin.group
        this.description = description
    }

    /**
     * A solution to allow external generation directory config which also allows unit testing for init.
     * It will try a system property named 'init.dir' and then fallback to the 'user.dir' property value.
     */
    protected String defaultDir(){
        System.getProperty( 'init.dir', System.getProperty('user.dir') )
    }

    /**
     * Determine the project path directory based on the specified project name.
     *
     * If the "projectParentDir" is not specified as a property, the user will be prompted for it.
     *
     * @param projectName the project name
     * @return the project directory path
     */
    protected String projectPath( final String projectName ){
        String parentDir = project.properties[PROJECT_PARENT_DIR]
        if( parentDir ){
            return "$parentDir/$projectName"
        } else {
            String dir = TemplatesPlugin.prompt( 'Project Parent Directory:', defaultDir() )
            return "$dir/$projectName"
        }
    }

    /**
     * Determine the project name to be used. If the 'newProjectName' is not specified as a property, the user will
     * be prompted for it.
     *
     * @return the project name to be used
     */
    protected String projectName(){
        project.properties[NEW_PROJECT_NAME] ?: TemplatesPlugin.prompt('Project Name:')
    }

    /**
     * Determine the project group to be used based on the project name. If the 'projectGroup' is not specified as a
     * property, the user will be prompted for it.
     *
     * @param projectName the project name
     * @return the project group
     */
    protected String projectGroup( final String projectName ){
        project.properties[PROJECT_GROUP] ?: TemplatesPlugin.prompt('Group:', projectName.toLowerCase())
    }

    /**
     * Determine the project version to be used. If the 'projectVersion' is not specified as a property the user will
     * be prompted for it.
     *
     * @return the project version
     */
    protected String projectVersion(){
        project.properties[PROJECT_VERSION] ?: TemplatesPlugin.prompt('Version:', '0.1')
    }

    /**
     * Ensures that the specified file exists under the current default directory. The file reference is returned.
     *
     * @param file the file suffix to ensure
     * @return the existing file
     */
    protected File ensureFileExists( final String file ){
        File buildFile = new File(defaultDir(), file)

        if( !buildFile.exists() ){
            buildFile.createNewFile()
        }

        return buildFile
    }
}


================================================
FILE: src/main/groovy/templates/tasks/AbstractTemplateExportTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import templates.TemplatesPlugin

/**
 * Abstract base task for template exporters.
 */
abstract class AbstractTemplateExportTask extends DefaultTask {

    private final templatePaths = []

    /**
     * Creates a new template export task with the given properties and templates.
     *
     * @param name the task name
     * @param description the task description
     * @param paths the template paths
     */
    protected AbstractTemplateExportTask( final String name, final String description, final paths = []){
        this.name = name
        this.group = TemplatesPlugin.group
        this.description = description
        this.templatePaths = paths
    }

    /**
     * Exports the configured templates.
     */
    @TaskAction void export(){
        exportTemplates templatePaths
    }

    private void exportTemplates(def templates = []) {
        templates.ProjectTemplate.fromUserDir {
            templates.each { template ->
                def tStream = getClass().getResourceAsStream(template)
                "$template" tStream.text
            }
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/gradle/AbstractGradleProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.gradle

import templates.JavaTemplatesPlugin
import templates.ProjectTemplate
import templates.TemplatesPlugin
import templates.tasks.AbstractProjectTask

/**
 *
 */
abstract class AbstractGradleProjectTask extends AbstractProjectTask {

    static final String PLUGIN_APPLY_LABEL = 'pluginApplyLabel'
    static final String PLUGIN_CLASS_NAME = 'pluginClassName'

    AbstractGradleProjectTask( final String name, final String description ){
        super( name, description )
    }

    /**
     * Creates the default project structure for a new gradle plugin.
     * @param path The root path of the project. optional, defaults to user.dir.
     * @param project A project object.
     */
    protected void createBase(String path = defaultDir(), def project) {

        def props = project.properties
        String lProjectName = project.name.toLowerCase()
        String cProjectName = project.name.capitalize()
        String projectGroup = props[ PROJECT_GROUP ] ?: TemplatesPlugin.prompt('Group:', lProjectName)
        String projectVersion = props[ PROJECT_VERSION ] ?: TemplatesPlugin.prompt('Version:', '1.0')
        String pluginApplyLabel = props[ PLUGIN_APPLY_LABEL ] ?: TemplatesPlugin.prompt('Plugin \'apply\' label:', lProjectName)
        String pluginClassName = props[ PLUGIN_CLASS_NAME ] ?: TemplatesPlugin.prompt('Plugin class name:', "${projectGroup}.${cProjectName}Plugin")

        createGroovyBase( path )

        ProjectTemplate.fromRoot(path){
            'src/main/' {
                'resources/META-INF/gradle-plugins' {
                    "${pluginApplyLabel}.properties" "implementation-class=${pluginClassName}"
                }
                'groovy' {
                    if (pluginClassName) {
                        def classParts = JavaTemplatesPlugin.getClassParts(pluginClassName)
                        "${classParts.classPackagePath}" {
                            "${classParts.className}.groovy" template: '/templates/plugin/plugin-class.tmpl',
                                className: classParts.className,
                                classPackage: classParts.classPackage
                            "${classParts.className}Convention.groovy" template: '/templates/plugin/convention-class.tmpl',
                                className: classParts.className,
                                classPackage: classParts.classPackage
                        }
                    }
                }
            }
            'build.gradle' template: '/templates/plugin/build.gradle.tmpl', projectGroup: projectGroup
            'gradle.properties' content: "version=${projectVersion}", append: true
        }
    }

    // FIXME: a bit of duplicated code to start with, need to refactor away
    private void createGroovyBase( path ){
        ProjectTemplate.fromRoot(path) {
            'src' {
                'main' {
                    'groovy' {}
                    'resources' {}
                }
                'test' {
                    "groovy" {}
                    "resources" {}
                }
            }
            'LICENSE.txt' '// Your License Goes here'
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/gradle/CreateGradlePluginTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.gradle
import org.gradle.api.tasks.TaskAction

/**
 * Task to create a gradle project in a new directory.
 */
class CreateGradlePluginTask extends AbstractGradleProjectTask {

    CreateGradlePluginTask(){
        super(
            'createGradlePlugin',
            'Creates a new Gradle Plugin project in a new directory named after your project.'
        )
    }

    @TaskAction void create(){
        def projectName = projectName()
        if (projectName) {
            createBase(
                projectPath( projectName ),
                [
                    name:projectName,
                    properties:project.properties
                ]
            )

        } else {
            // FIXME: error
            println 'No project name provided.'
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/gradle/ExportPluginTemplatesTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.gradle

import templates.tasks.AbstractTemplateExportTask

/**
 * Task to export the default gradle project templates.
 */
class ExportPluginTemplatesTask extends AbstractTemplateExportTask {

    ExportPluginTemplatesTask(){
        super(
            'exportPluginTemplates',
            'Exports the default plugin template files into the current directory.',
            [
                '/templates/plugin/build.gradle.tmpl',
                '/templates/plugin/convention-class.tmpl',
                '/templates/plugin/plugin-class.tmpl'
            ]
        )
    }
}


================================================
FILE: src/main/groovy/templates/tasks/gradle/InitGradlePluginTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.gradle
import org.gradle.api.tasks.TaskAction

/**
 * Task to initialize a new gradle plugin project in the current directory.
 */
class InitGradlePluginTask extends AbstractGradleProjectTask {

    InitGradlePluginTask(){
        super(
            'initGradlePlugin',
            'Initializes a new Gradle Plugin project in the current directory.'
        )
    }

    @TaskAction def init(){
        createBase project
    }
}


================================================
FILE: src/main/groovy/templates/tasks/groovy/AbstractGroovyProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.groovy
import templates.ProjectTemplate
import templates.tasks.AbstractProjectTask
/**
 *
 */
abstract class AbstractGroovyProjectTask extends AbstractProjectTask {

    AbstractGroovyProjectTask( final String name, final String description ){
        super( name, description )
    }

    /**
     * Creates the basic Groovy project directory structure.
     * @param path the root of the project. Optional,defaults to user.dir.
     */
    protected void createBase(String path = defaultDir() ) {
        ProjectTemplate.fromRoot(path) {
            'src' {
                'main' {
                    'groovy' {}
                    'resources' {}
                }
                'test' {
                    "groovy" {}
                    "resources" {}
                }
            }
            'LICENSE.txt' '// Your License Goes here'
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/groovy/CreateGroovyClassTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.groovy

import org.gradle.api.Project
import org.gradle.api.tasks.TaskAction
import templates.JavaTemplatesPlugin
import templates.ProjectTemplate
import templates.TemplatesPlugin

/**
 * Task to create a new Groovy class in the current project.
 */
class CreateGroovyClassTask extends AbstractGroovyProjectTask {

    public static final String NEW_CLASS_NAME = 'newClassName'

    CreateGroovyClassTask(){
        super(
            'createGroovyClass',
            'Creates a new Groovy class in the current project.'
        )
    }

    @TaskAction def create(){
        def mainSrcDir = null
        try {
            // get main groovy dir, and check to see if Groovy plugin is installed.
            mainSrcDir = findMainGroovyDir(project)
        } catch (Exception e) {
            throw new IllegalStateException('It seems that the Groovy plugin is not installed, I cannot determine the main groovy source directory.', e)
        }

        def fullClassName = project.properties[NEW_CLASS_NAME] ?: TemplatesPlugin.prompt('Class name (com.example.MyClass)')

        if (fullClassName) {
            def classParts = JavaTemplatesPlugin.getClassParts(fullClassName)
            ProjectTemplate.fromUserDir {
                "${mainSrcDir}" {
                    "${classParts.classPackagePath}" {
                        "${classParts.className}.groovy" template: '/templates/groovy/groovy-class.tmpl',
                            className: classParts.className,
                            classPackage: classParts.classPackage
                    }
                }
            }
        } else {
            println 'No class name provided.'
        }
    }

    // FIXME: these finders are all very similar, refactor
    /**
     * Finds the path to the main java source directory.
     * @param project The project.
     * @return The path to the main groovy source directory.
     */
    private static String findMainGroovyDir(Project project) {
        def mainSrcDir = project.sourceSets?.main?.groovy?.srcDirs*.path
        mainSrcDir = mainSrcDir?.first()
        mainSrcDir = mainSrcDir?.minus(project.projectDir.path)
        return mainSrcDir
    }
}


================================================
FILE: src/main/groovy/templates/tasks/groovy/CreateGroovyProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.groovy
import org.gradle.api.tasks.TaskAction
import templates.ProjectTemplate

/**
 * Task to create a Groovy Gradle project in a new directory.
 */
class CreateGroovyProjectTask extends AbstractGroovyProjectTask {

    CreateGroovyProjectTask(){
        super(
            'createGroovyProject',
            'Creates a new Gradle Groovy project in a new directory named after your project.'
        )
    }

    @TaskAction def create(){
        String projectName = projectName()
        if (projectName) {
            String projectPath = projectPath( projectName )

            createBase projectPath

            ProjectTemplate.fromRoot(projectPath) {
                'build.gradle' template:'/templates/groovy/build.gradle.tmpl', projectGroup:projectGroup(projectName)
                'gradle.properties' content:"version=${projectVersion()}", append:true
            }

        } else {
            // FIXME: should be an error
            println 'No project name provided.'
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/groovy/ExportGroovyTemplatesTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.groovy

import templates.tasks.AbstractTemplateExportTask

/**
 * Task to export the default groovy templates.
 */
class ExportGroovyTemplatesTask extends AbstractTemplateExportTask {

    ExportGroovyTemplatesTask(){
        super(
            'exportGroovyTemplates',
            'Exports the default groovy template files into the current directory.',
            [
                '/templates/groovy/build.gradle.tmpl',
                '/templates/groovy/groovy-class.tmpl'
            ]
        )
    }
}


================================================
FILE: src/main/groovy/templates/tasks/groovy/InitGroovyProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.groovy

import org.gradle.api.tasks.TaskAction
import templates.TemplatesPlugin

/**
 * Task to initialize a groovy project.
 */
class InitGroovyProjectTask extends AbstractGroovyProjectTask {

    InitGroovyProjectTask(){
        super(
            'initGroovyProject',
            'Initializes a new Gradle Groovy project in the current directory.'
        )
    }

    @TaskAction def init(){
        createBase()

        File buildFile = ensureFileExists('build.gradle')

        TemplatesPlugin.prependPlugin 'groovy', buildFile
    }
}


================================================
FILE: src/main/groovy/templates/tasks/java/AbstractJavaProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.java
import templates.ProjectTemplate
import templates.tasks.AbstractProjectTask
/**
 * Base class for Java project tasks.
 */
abstract class AbstractJavaProjectTask extends AbstractProjectTask {

    AbstractJavaProjectTask( final String name, final String description ){
        super( name, description )
    }

    /**
     * Creates the basic Java project directory structure.
     *
     * @param path the root of the project. Optional,defaults to user.dir.
     */
    protected void createBase(String path = defaultDir() ){
        ProjectTemplate.fromRoot(path) {
            'src' {
                'main' {
                    'java' {}
                    'resources' {}
                }
                'test' {
                    'java' {}
                    'resources' {}
                }
            }
            'LICENSE.txt' '// Your License Goes here'
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/java/CreateJavaClassTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.java

import org.gradle.api.Project
import org.gradle.api.tasks.TaskAction
import templates.JavaTemplatesPlugin
import templates.ProjectTemplate
import templates.TemplatesPlugin

/**
 * Task to create a new Java class in the current project.
 */
class CreateJavaClassTask extends AbstractJavaProjectTask {

    // TODO: the property names should be standardized and in a shared location
    public static final String NEW_CLASS_NAME = 'newClassName'

    CreateJavaClassTask(){
        super(
            'createJavaClass',
            'Creates a new Java class in the current project.'
        )
    }

    @TaskAction def create(){
        def mainSrcDir = null
        try {
            // get main java dir, and check to see if Java plugin is installed.
            mainSrcDir = findMainJavaDir(project)
        } catch (Exception e) {
            throw new IllegalStateException('It seems that the Java plugin is not installed, I cannot determine the main java source directory.', e)
        }

        def fullClassName = project.properties[NEW_CLASS_NAME] ?: TemplatesPlugin.prompt('Class name (com.example.MyClass)')
        if (fullClassName) {
            def classParts = JavaTemplatesPlugin.getClassParts(fullClassName)
            ProjectTemplate.fromUserDir {
                "${mainSrcDir}" {
                    "${classParts.classPackagePath}" {
                        "${classParts.className}.java" template: '/templates/java/java-class.tmpl',
                            classPackage: classParts.classPackage,
                            className: classParts.className
                    }
                }
            }
        } else {
            // TODO: should be an error
            println 'No class name provided.'
        }
    }

    /**
     * Finds the path to the main java source directory.
     *
     * @param project The project.
     * @return The path to the main java source directory.
     */
    private static String findMainJavaDir( final Project project ){
        def mainSrcDir = project.sourceSets?.main?.java?.srcDirs*.path
        mainSrcDir = mainSrcDir?.first()
        mainSrcDir = mainSrcDir?.minus(project.projectDir.path)
        return mainSrcDir
    }
}


================================================
FILE: src/main/groovy/templates/tasks/java/CreateJavaProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.java
import org.gradle.api.tasks.TaskAction
import templates.ProjectTemplate

/**
 * Task that creates a new java project in a specified directory.
 */
class CreateJavaProjectTask extends AbstractJavaProjectTask {

    CreateJavaProjectTask(){
        super(
            'createJavaProject',
            'Creates a new Gradle Java project in a new directory named after your project.'
        )
    }

    @TaskAction void create(){
        String projectName = projectName()
        if (projectName) {
            String projectPath = projectPath( projectName )

            createBase projectPath

            ProjectTemplate.fromRoot(projectPath) {
                'build.gradle' template:'/templates/java/build.gradle.tmpl', projectGroup:projectGroup(projectName)
                'gradle.properties' content:"version=${projectVersion()}", append:true
            }

        } else {
            // FIXME: should be an error
            println 'No project name provided.'
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/java/ExportJavaTemplatesTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.java

import templates.tasks.AbstractTemplateExportTask

/**
 *  Task to export the default java templates into the current directory.
 */
class ExportJavaTemplatesTask extends AbstractTemplateExportTask {

    ExportJavaTemplatesTask(){
        super(
            'exportJavaTemplates',
            'Exports the default java template files into the current directory.',
            [
                '/templates/java/build.gradle.tmpl',
                '/templates/java/java-class.tmpl'
            ]
        )
    }
}


================================================
FILE: src/main/groovy/templates/tasks/java/InitJavaProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.java

import org.gradle.api.tasks.TaskAction
import templates.TemplatesPlugin

/**
 * Task to initialize a gradle Java project in the current directory.
 */
class InitJavaProjectTask extends AbstractJavaProjectTask {

    InitJavaProjectTask(){
        super(
            'initJavaProject',
            'Initializes a new Gradle Java project in the current directory.'
        )
    }

    @TaskAction def init(){
        createBase()

        File buildFile = ensureFileExists( 'build.gradle')

        TemplatesPlugin.prependPlugin 'java', buildFile
    }
}


================================================
FILE: src/main/groovy/templates/tasks/scala/AbstractScalaProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala

import org.gradle.api.Project
import templates.ProjectTemplate
import templates.TemplatesPlugin
import templates.tasks.AbstractProjectTask

/**
 * Base class for Scala tasks.
 */
abstract class AbstractScalaProjectTask extends AbstractProjectTask {

    static final String SCALA_VERSION = 'scalaVersion'
    static final String USE_FAST_SCALA_COMPILER = 'useFastScalaCompiler'

    AbstractScalaProjectTask( final String name, final String description ){
        super( name, description )
    }

    /**
     * Creates the basic Scala project directory structure.
     *
     * @param path the root of the project. Optional,defaults to user.dir.
     */
    protected void createBase(String path = defaultDir() ){
        ProjectTemplate.fromRoot(path) {
            'src' {
                'main' {
                    'scala' {}
                    'resources' {}
                }
                'test' {
                    'scala' {}
                    'resources' {}
                }
            }
            'LICENSE.txt' '// Your License Goes here'
        }
    }

    /**
     * Initializes or creates the project's build.gradle file.
     *
     * @param project The project
     * @param path The path to the root of the project. optional, defaults to user.dir.
     */
    protected void setupBuildFile(Project project, String path = defaultDir() ) {
        def props = project.properties

        String scalaVersion = props[SCALA_VERSION] ?: TemplatesPlugin.prompt('Scala Version:', '2.9.0')

        boolean useFastCompiler = props[USE_FAST_SCALA_COMPILER] ?: TemplatesPlugin.promptYesOrNo('Use fast compiler?', false)

        ProjectTemplate.fromRoot(path) {
            'build.gradle' template: '/templates/scala/build.gradle.tmpl', append: true,
                scalaVersion: scalaVersion,
                useFastCompiler: useFastCompiler,
                projectGroup: props[AbstractProjectTask.PROJECT_GROUP]
            'gradle.properties' content: "version=${props[AbstractProjectTask.PROJECT_VERSION] ?: '0.1'}", append: true
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/scala/CreateScalaClassTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala

import org.gradle.api.Project
import org.gradle.api.tasks.TaskAction
import templates.JavaTemplatesPlugin
import templates.ProjectTemplate
import templates.TemplatesPlugin

/**
 * Task for creating a new scala class in the current project.
 */
class CreateScalaClassTask extends AbstractScalaProjectTask {

    protected static final String NEW_CLASS_NAME = 'newClassName'
    protected static final String NEW_OBJECT_NAME = 'newObjectName'

    CreateScalaClassTask(){
        super(
            'createScalaClass',
            'Creates a new Scala class in the current project.'
        )
    }

    @TaskAction
    def create(){
        createScalaClass project, false
    }

    /**
     * Creates a Scala class, or object in the current working directory.
     *
     * @param project The project.
     * @param object Is this a Scala class, or object.
     */
    protected void createScalaClass(Project project, boolean object) {
        def mainSrcDir = null
        try {
            // get main Scala dir, and check to see if Scala plugin is installed.
            mainSrcDir = findMainScalaDir(project)
        } catch (Exception e) {
            throw new IllegalStateException('It seems that the Scala plugin is not installed, I cannot determine the main scala source directory.', e)
        }

        def props = project.properties
        def type = object ? 'Object' : 'Class'

        // TODO: seems like we'd only need one name that works for either case
        def fullClassName = props[NEW_CLASS_NAME] ?: props[NEW_OBJECT_NAME] ?: TemplatesPlugin.prompt("${type} name (com.example.My${type})")

        if (fullClassName) {
            def classParts = JavaTemplatesPlugin.getClassParts(fullClassName)
            ProjectTemplate.fromUserDir {
                "${mainSrcDir}" {
                    "${classParts.classPackagePath}" {
                        "${classParts.className}.scala" template: '/templates/scala/scala-class.tmpl',
                            className: classParts.className,
                            classPackage: classParts.classPackage,
                            object: object
                    }
                }
            }

        } else {
            // TODO: should be an error of some sort
            println 'No class name provided.'
        }
    }

    /**
     * Finds the path to the main java source directory.
     *
     * @param project The project.
     * @return The path to the main groovy source directory.
     */
    protected static String findMainScalaDir( final Project project ){
        def mainSrcDir = project.sourceSets?.main?.scala?.srcDirs*.path
        mainSrcDir = mainSrcDir?.first()
        mainSrcDir = mainSrcDir?.minus(project.projectDir.path)
        return mainSrcDir
    }
}


================================================
FILE: src/main/groovy/templates/tasks/scala/CreateScalaObjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala
import org.gradle.api.tasks.TaskAction

/**
 * Task for creating a new scala object in the current project.
 */
class CreateScalaObjectTask extends CreateScalaClassTask {
    // TODO: seems like there should be a better way to do this since its just a different property

    CreateScalaObjectTask(){
        super()
        name = 'createScalaObject'
        description = 'Creates a new Scala object in the current project.'
    }

    @Override @TaskAction
    def create(){
        createScalaClass project, true
    }
}


================================================
FILE: src/main/groovy/templates/tasks/scala/CreateScalaProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala
import org.gradle.api.tasks.TaskAction

/**
 * Task for creating a new Gradle Scala project in a specified directory.
 */
class CreateScalaProjectTask extends AbstractScalaProjectTask {

    CreateScalaProjectTask(){
        super(
            'createScalaProject',
            'Creates a new Gradle Scala project in a new directory named after your project.'
        )
    }

    @TaskAction void create(){
        String projectName = projectName()
        if (projectName) {
            project.ext[PROJECT_GROUP] = projectGroup( projectName )
            project.ext[PROJECT_VERSION] = projectVersion()

            String projectPath = projectPath( projectName )

            createBase projectPath
            setupBuildFile project, projectPath

        } else {
            // FIXME: error
            println 'No project name provided.'
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/scala/ExportScalaTemplatesTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala

import templates.tasks.AbstractTemplateExportTask

/**
 * Task to export the scala templates.
 */
class ExportScalaTemplatesTask extends AbstractTemplateExportTask {

    ExportScalaTemplatesTask(){
        super(
            'exportScalaTemplates',
            'Exports the default scala template files into the current directory.',
            [
                '/templates/scala/build.gradle.tmpl',
                '/templates/scala/scala-class.tmpl'
            ]
        )
    }
}


================================================
FILE: src/main/groovy/templates/tasks/scala/InitScalaProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala
import org.gradle.api.tasks.TaskAction
/**
 * Task for initializing a new Gradle Scala project in the current directory.
 */
class InitScalaProjectTask extends AbstractScalaProjectTask {

    InitScalaProjectTask(){
        super(
            'initScalaProject',
            'Initializes a new Gradle Scala project in the current directory.'
        )
    }

    @TaskAction
    def init(){
        createBase()
        setupBuildFile(project)
    }
}


================================================
FILE: src/main/groovy/templates/tasks/webapp/AbstractWebappProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.webapp

import templates.ProjectTemplate
import templates.TemplatesPlugin
import templates.tasks.AbstractProjectTask

/**
 *
 */
abstract class AbstractWebappProjectTask extends AbstractProjectTask {

    static final String USE_JETTY_PLUGIN = 'useJettyPlugin'

    AbstractWebappProjectTask( final String name, final String description ){
        super( name, description )
    }

    /**
     * Creates the basic Groovy project directory structure.
     * @param path the root of the project. Optional,defaults to user.dir.
     */
    protected void createBase(String path = defaultDir(), String projectName) {
        createJavaBase path

        ProjectTemplate.fromRoot(path) {
            'src/main/webapp/WEB-INF' {
                'web.xml' template: '/templates/webapp/web-xml.tmpl', project: [name: projectName]
            }
        }
    }

    protected boolean useJetty(){
        if( project.properties[USE_JETTY_PLUGIN] ){
            return project.properties[USE_JETTY_PLUGIN]?.toLowerCase() == 'y'
        } else {
            return TemplatesPlugin.promptYesOrNo('Use Jetty Plugin?')
        }
    }

    // FIXME: copied from AbstractJavaProjectTask
    private void createJavaBase(String path = defaultDir() ){
        ProjectTemplate.fromRoot(path) {
            'src' {
                'main' {
                    'java' {}
                    'resources' {}
                }
                'test' {
                    'java' {}
                    'resources' {}
                }
            }
            'LICENSE.txt' '// Your License Goes here'
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/webapp/CreateWebappProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.webapp
import org.gradle.api.tasks.TaskAction
import templates.ProjectTemplate
/**
 * Task to create a new gradle web app project in a directory.
 */
class CreateWebappProjectTask extends AbstractWebappProjectTask {

    CreateWebappProjectTask(){
        super(
            'createWebappProject',
            'Creates a new Gradle Webapp project in a new directory named after your project.'
        )
    }

    @TaskAction def create(){
        String projectName = projectName()
        if (projectName) {
            String projectPath = projectPath( projectName )

            createBase projectPath, projectName

            ProjectTemplate.fromRoot(projectPath) {
                'build.gradle' template:'/templates/webapp/build.gradle.tmpl', useJetty:useJetty(), projectGroup:projectGroup(projectName)
                'gradle.properties' content:"version=${projectVersion()}", append:true
            }

        } else {
            // FIXME: error here
            println 'No project name provided.'
        }
    }
}


================================================
FILE: src/main/groovy/templates/tasks/webapp/ExportWebappTemplatesTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.webapp

import templates.tasks.AbstractTemplateExportTask

/**
 * Task to export the default webapp templates.
 */
class ExportWebappTemplatesTask extends AbstractTemplateExportTask {

    ExportWebappTemplatesTask(){
        super(
            'exportWebappTemplates',
            'Exports the default webapp template files into the current directory.',
            [
                '/templates/webapp/build.gradle.tmpl',
                '/templates/webapp/web-xml.tmpl'
            ]
        )
    }
}


================================================
FILE: src/main/groovy/templates/tasks/webapp/InitWebappProjectTask.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.webapp

import org.gradle.api.tasks.TaskAction
import templates.TemplatesPlugin

/**
 * Task to initialize a webapp project.
 */
class InitWebappProjectTask extends AbstractWebappProjectTask {

    InitWebappProjectTask(){
        super(
            'initWebappProject',
            'Initializes a new Gradle Webapp project in the current directory.'
        )
    }

    @TaskAction def init(){
        createBase project.name

        File buildFile = ensureFileExists( 'build.gradle' )

        TemplatesPlugin.prependPlugin useJetty() ? 'jetty' : 'war', buildFile
    }
}


================================================
FILE: src/main/resources/META-INF/gradle-plugins/gradle-plugin-templates.properties
================================================
implementation-class=templates.GradlePluginTemplatesPlugin

================================================
FILE: src/main/resources/META-INF/gradle-plugins/groovy-templates.properties
================================================
implementation-class=templates.GroovyTemplatesPlugin

================================================
FILE: src/main/resources/META-INF/gradle-plugins/java-templates.properties
================================================
implementation-class=templates.JavaTemplatesPlugin

================================================
FILE: src/main/resources/META-INF/gradle-plugins/scala-templates.properties
================================================
implementation-class=templates.ScalaTemplatesPlugin

================================================
FILE: src/main/resources/META-INF/gradle-plugins/templates.properties
================================================
implementation-class=templates.TemplatesPlugin

================================================
FILE: src/main/resources/META-INF/gradle-plugins/webapp-templates.properties
================================================
implementation-class=templates.WebappTemplatesPlugin

================================================
FILE: src/main/resources/templates/groovy/build.gradle.tmpl
================================================
apply plugin: 'groovy'

group = '${projectGroup}'

dependencies {
   groovy localGroovy()
}

================================================
FILE: src/main/resources/templates/groovy/groovy-class.tmpl
================================================
package ${classPackage}

/**
 * @author ${System.getProperty('user.name')}
 * Created: ${new Date()}
 */
class ${className} {

}

================================================
FILE: src/main/resources/templates/java/build.gradle.tmpl
================================================
apply plugin: 'java'

group = '${projectGroup}'

================================================
FILE: src/main/resources/templates/java/java-class.tmpl
================================================
package ${classPackage};

/**
 * @author ${System.getProperty('user.name')}
 * Created: ${new Date()}
 */
public class ${className} {
   public ${className}() {
   
   }
}

================================================
FILE: src/main/resources/templates/plugin/build.gradle.tmpl
================================================
apply plugin: 'groovy'

group = '${projectGroup}'

dependencies {
   compile gradleApi()
   groovy localGroovy()
}


================================================
FILE: src/main/resources/templates/plugin/convention-class.tmpl
================================================
package ${classPackage}

/**
 * @author ${System.getProperty('user.name')}
 * Created: ${new Date()}
 */
class ${className}Convention {

}

================================================
FILE: src/main/resources/templates/plugin/plugin-class.tmpl
================================================
package ${classPackage}

import org.gradle.api.Project
import org.gradle.api.Plugin

/**
 * @author ${System.getProperty('user.name')}
 * Created: ${new Date()}
 */
class ${className} implements Plugin<Project> {
   void apply (Project project) {
      project.convention.plugins.${className} = new ${className}Convention()
      
      // add your plugin tasks here.
   }
}

================================================
FILE: src/main/resources/templates/scala/build.gradle.tmpl
================================================
apply plugin: 'scala'

<% if(projectGroup){ %>
group = '${projectGroup}'
<% } %>

repositories {
	mavenCentral()
}

scalaVersion = '${scalaVersion}'

dependencies {
	// Libraries needed to run the scala tools
	scalaTools "org.scala-lang:scala-compiler:\${scalaVersion}",
	           "org.scala-lang:scala-library:\${scalaVersion}"

	// Libraries needed for scala api
	compile "org.scala-lang:scala-library:\${scalaVersion}"
}

<% if (useFastCompiler) { %>
compileScala {
	scalaCompileOptions.useCompileDaemon = true

	// optionally specify host and port of the daemon:
	scalaCompileOptions.daemonServer = 'localhost:4243'
}
<% } %>

================================================
FILE: src/main/resources/templates/scala/scala-class.tmpl
================================================
package ${classPackage}

/**
 * @author ${System.getProperty('user.name')}
 * Created: ${new Date()}
 */
${object ? 'object' : 'class'} ${className} {

}

================================================
FILE: src/main/resources/templates/webapp/build.gradle.tmpl
================================================
${useJetty ? 'apply plugin: \'jetty\'' : 'apply plugin: \'war\''}

group = '${projectGroup}'

================================================
FILE: src/main/resources/templates/webapp/web-xml.tmpl
================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
   <!-- General description of your web application -->
   <display-name>${project.name} - Webapp</display-name>
      <description>
         Describe the ${project.name} Webapp here.
         ${System.getProperty('user.name')}@example.com

         See http://tomcat.apache.org/tomcat-6.0-doc/appdev/web.xml.txt for more information
         regarding this Web Descriptor File.
   </description>
</web-app>

================================================
FILE: src/test/groovy/templates/AbstractTaskTester.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates

import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.testfixtures.ProjectBuilder
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.rules.TemporaryFolder

/**
 * Base class for template-based task testers.
 */
abstract class AbstractTaskTester {

    @Rule
    public TemporaryFolder folder = new TemporaryFolder()

    protected Project project
    protected Task task

    private final Class taskClass

    AbstractTaskTester( final Class taskClass ){
        this.taskClass = taskClass
    }

    @Before
    void before(){
        System.setProperty( 'init.dir', folder.root as String )

        project = ProjectBuilder.builder().build()
        task = project.task( 'targetTask', type:taskClass )
    }

    @After void after(){
        System.setProperty( 'init.dir', '' )
    }

    /**
     * Asserts that the specified file exists.
     *
     * @param root the root directory
     * @param path the path to the file
     */
    protected void assertFileExists( File root, String path ){
        assert new File( root, path ).exists()
    }

    /**
     * Asserts that the file at the given path (root+path) exists and that it contains the specified
     * content strings.
     *
     * @param root the root directory
     * @param path the path to the file
     * @param contents the content string to be tested
     */
    protected void assertFileContains( File root, String path, String... contents ){
        assertFileExists root, path

        String text = new File( root, path ).text

        contents.each { String str ->
            assert text.contains( str )
        }
    }
}


================================================
FILE: src/test/groovy/templates/GradlePluginTemplatesPluginTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates

import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder

class GradlePluginTemplatesPluginTest {

    @Rule public TemporaryFolder rootFolder = new TemporaryFolder()

    @Test void 'apply'(){
        Project project = ProjectBuilder.builder().build()
        project.apply plugin: 'templates'

        assert project.tasks.createGradlePlugin
        assert project.tasks.exportPluginTemplates
        assert project.tasks.initGradlePlugin
    }
}


================================================
FILE: src/test/groovy/templates/GroovyTemplatesPluginTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Test

class GroovyTemplatesPluginTest {

    @Test void 'apply'(){
        Project project = ProjectBuilder.builder().build()
        project.apply plugin: 'templates'

        assert project.tasks.createGroovyClass
        assert project.tasks.createGroovyProject
        assert project.tasks.exportGroovyTemplates
        assert project.tasks.initGroovyProject
    }
}


================================================
FILE: src/test/groovy/templates/JavaTemplatesPluginTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Test

class JavaTemplatesPluginTest {

    @Test void 'apply'(){
        Project project = ProjectBuilder.builder().build()
        project.apply plugin: 'templates'

        assert project.tasks.createJavaClass
        assert project.tasks.createJavaProject
        assert project.tasks.exportJavaTemplates
        assert project.tasks.initJavaProject
    }
}


================================================
FILE: src/test/groovy/templates/ProjectTemplateTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder

class ProjectTemplateTest {

    private static final String PROJECT_NAME = 'some_project'

    @Rule public TemporaryFolder rootFolder = new TemporaryFolder()

    @Test void 'fromRoot(String): empty'(){
        assert !(new File( rootFolder.root, PROJECT_NAME ).exists())

        ProjectTemplate.fromRoot( "${rootFolder.root}/$PROJECT_NAME" )

        assert new File( rootFolder.root, PROJECT_NAME ).exists()
    }

    @Test void 'fromRoot(String): with content'(){
        assert !(new File( rootFolder.root, PROJECT_NAME ).exists())

        File templateFile = rootFolder.newFile( 'template.tmpl' )
        templateFile.text = 'The answer is ${bar}'

        ProjectTemplate.fromRoot( "${rootFolder.root}/$PROJECT_NAME" ){
            'stuff' {
                'README.txt' '''
                    This is a generated README file.
                '''
                'deeper' {}
                'foo' template:templateFile.toString(), bar:42
            }
        }

        assert new File( rootFolder.root, PROJECT_NAME ).exists()
        assert new File( rootFolder.root, "$PROJECT_NAME/stuff" ).exists()
        assert new File( rootFolder.root, "$PROJECT_NAME/stuff/deeper" ).exists()

        assertFileText rootFolder.root, "$PROJECT_NAME/stuff/README.txt", 'This is a generated README file.'
        assertFileText rootFolder.root, "$PROJECT_NAME/stuff/foo", 'The answer is 42'
    }

    private void assertFileText( File dir, String path, String expectedText ){
        def targetFile = new File( dir, path )
        assert targetFile.exists()
        assert targetFile.text.trim() == expectedText
    }

    @Test void 'fromRoot(File): empty'(){
        assert !(new File( rootFolder.root, PROJECT_NAME ).exists())

        ProjectTemplate.fromRoot( new File( rootFolder.root, PROJECT_NAME ) )

        assert new File( rootFolder.root, PROJECT_NAME ).exists()
    }
}


================================================
FILE: src/test/groovy/templates/ScalaTemplatesPluginTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Test

class ScalaTemplatesPluginTest {

    @Test void 'apply'(){
        Project project = ProjectBuilder.builder().build()
        project.apply plugin: 'templates'

        assert project.tasks.createScalaClass
        assert project.tasks.createScalaObject
        assert project.tasks.createScalaProject
        assert project.tasks.exportScalaTemplates
        assert project.tasks.initScalaProject
    }
}



================================================
FILE: src/test/groovy/templates/TemplatesPluginTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Test

class TemplatesPluginTest {

    @Test void 'apply'(){
        Project project = ProjectBuilder.builder().build()
        project.apply plugin: 'templates'

        assert project.tasks.exportAllTemplates

        assert project.tasks.createGradlePlugin
        assert project.tasks.exportPluginTemplates
        assert project.tasks.initGradlePlugin

        assert project.tasks.createGroovyClass
        assert project.tasks.createGroovyProject
        assert project.tasks.exportGroovyTemplates
        assert project.tasks.initGroovyProject

        assert project.tasks.createJavaClass
        assert project.tasks.createJavaProject
        assert project.tasks.exportJavaTemplates
        assert project.tasks.initJavaProject

        assert project.tasks.createScalaClass
        assert project.tasks.createScalaObject
        assert project.tasks.createScalaProject
        assert project.tasks.exportScalaTemplates
        assert project.tasks.initScalaProject

        assert project.tasks.createWebappProject
        assert project.tasks.exportWebappTemplates
        assert project.tasks.initWebappProject
    }

}


================================================
FILE: src/test/groovy/templates/WebappTemplatesPluginTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Test

class WebappTemplatesPluginTest {

    @Test void 'apply'(){
        Project project = ProjectBuilder.builder().build()
        project.apply plugin: 'templates'

        assert project.tasks.createWebappProject
        assert project.tasks.exportWebappTemplates
        assert project.tasks.initWebappProject
    }
}


================================================
FILE: src/test/groovy/templates/tasks/gradle/CreateGradlePluginTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.gradle
import org.junit.Test
import templates.AbstractTaskTester

import static AbstractGradleProjectTask.NEW_PROJECT_NAME
import static AbstractGradleProjectTask.PROJECT_PARENT_DIR
import static AbstractGradleProjectTask.PROJECT_GROUP
import static AbstractGradleProjectTask.PROJECT_VERSION
import static AbstractGradleProjectTask.PLUGIN_CLASS_NAME
import static AbstractGradleProjectTask.PLUGIN_APPLY_LABEL

class CreateGradlePluginTaskTest extends AbstractTaskTester {

    CreateGradlePluginTaskTest(){
        super( CreateGradlePluginTask )
    }

    @Test void create(){
        project.ext[PROJECT_PARENT_DIR] = folder.getRoot() as String
        project.ext[NEW_PROJECT_NAME] = 'tester'
        project.ext[PROJECT_GROUP] = 'test-group'
        project.ext[PROJECT_VERSION] = '1.1.1'
        project.ext[PLUGIN_APPLY_LABEL] = 'test-foo'
        project.ext[PLUGIN_CLASS_NAME] = 'com.test'

        task.create()

        assertFileExists folder.root, 'tester/src/main/groovy'
        assertFileExists folder.root, 'tester/src/main/resources'
        assertFileExists folder.root, 'tester/src/test/groovy'
        assertFileExists folder.root, 'tester/src/test/resources'
        assertFileExists folder.root, 'tester/LICENSE.txt'

        assertFileContains folder.root, 'tester/build.gradle', 'group = \'test-group\''
        assertFileContains folder.root, 'tester/gradle.properties', 'version=1.1.1'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/gradle/ExportPluginTemplatesTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.gradle
import org.junit.Test
import templates.AbstractTaskTester

class ExportPluginTemplatesTaskTest extends AbstractTaskTester {

    ExportPluginTemplatesTaskTest(){
        super( ExportPluginTemplatesTask )
    }

    @Test void export(){
        task.export()

        assertFileExists folder.root, 'templates/plugin/build.gradle.tmpl'
        assertFileExists folder.root, 'templates/plugin/convention-class.tmpl'
        assertFileExists folder.root, 'templates/plugin/plugin-class.tmpl'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/gradle/InitGradlePluginTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.gradle
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.gradle.AbstractGradleProjectTask.*

class InitGradlePluginTaskTest extends AbstractTaskTester{

    InitGradlePluginTaskTest(){
        super( InitGradlePluginTask )
    }

    @Test void init(){
        project.ext[PROJECT_PARENT_DIR] = folder.getRoot() as String
        project.ext[PROJECT_GROUP] = 'test-group'
        project.ext[PROJECT_VERSION] = '1.1.1'
        project.ext[PLUGIN_APPLY_LABEL] = 'test-foo'
        project.ext[PLUGIN_CLASS_NAME] = 'com.test'

        task.init()

        assertFileExists folder.root, 'src/main/groovy'
        assertFileExists folder.root, 'src/main/resources'
        assertFileExists folder.root, 'src/test/groovy'
        assertFileExists folder.root, 'src/test/resources'
        assertFileExists folder.root, 'LICENSE.txt'

        assertFileContains folder.root, 'build.gradle', 'group = \'test-group\''
        assertFileContains folder.root, 'gradle.properties', 'version=1.1.1'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/groovy/CreateGroovyClassTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.groovy
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.groovy.CreateGroovyClassTask.NEW_CLASS_NAME

/**
 * Created by cjstehno on 12/23/13.
 */
class CreateGroovyClassTaskTest extends AbstractTaskTester {

    CreateGroovyClassTaskTest(){
        super( CreateGroovyClassTask )
    }

    @Test void create(){
        project.apply plugin:'groovy'

        project.ext[NEW_CLASS_NAME] = 'foo.Something'

        task.create()

        assertFileContains folder.root, 'src/main/groovy/foo/Something.groovy', 'class Something'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/groovy/CreateGroovyProjectTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.groovy
import org.junit.Test
import templates.AbstractTaskTester

class CreateGroovyProjectTaskTest extends AbstractTaskTester {

    CreateGroovyProjectTaskTest(){
        super( CreateGroovyProjectTask )
    }

    @Test void create(){
        project.ext[ CreateGroovyProjectTask.PROJECT_PARENT_DIR] = folder.getRoot() as String
        project.ext[ CreateGroovyProjectTask.NEW_PROJECT_NAME] = 'tester'
        project.ext[ CreateGroovyProjectTask.PROJECT_GROUP] = 'test-group'
        project.ext[ CreateGroovyProjectTask.PROJECT_VERSION] = '1.1.1'

        task.create()

        assertFileExists folder.root, 'tester/src/main/groovy'
        assertFileExists folder.root, 'tester/src/main/resources'
        assertFileExists folder.root, 'tester/src/test/groovy'
        assertFileExists folder.root, 'tester/src/test/resources'
        assertFileExists folder.root, 'tester/LICENSE.txt'

        assertFileContains folder.root, 'tester/build.gradle', 'group = \'test-group\''
        assertFileContains folder.root, 'tester/gradle.properties', 'version=1.1.1'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/groovy/ExportGroovyTemplatesTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.groovy

import org.junit.Test
import templates.AbstractTaskTester

class ExportGroovyTemplatesTaskTest extends AbstractTaskTester {

    ExportGroovyTemplatesTaskTest(){
        super( ExportGroovyTemplatesTask )
    }

    @Test void export(){
        task.export()

        assertFileExists folder.root, 'templates/groovy/build.gradle.tmpl'
        assertFileExists folder.root, 'templates/groovy/groovy-class.tmpl'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/groovy/InitGroovyProjectTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.groovy
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.scala.AbstractScalaProjectTask.PROJECT_GROUP

class InitGroovyProjectTaskTest extends AbstractTaskTester {

    InitGroovyProjectTaskTest(){
        super( InitGroovyProjectTask )
    }

    @Test void init(){
        project.ext[PROJECT_GROUP] = 'test-group'

        task.init()

        assertFileExists folder.root, 'src/main/groovy'
        assertFileExists folder.root, 'src/main/resources'
        assertFileExists folder.root, 'src/test/groovy'
        assertFileExists folder.root, 'src/test/resources'
        assertFileExists folder.root, 'LICENSE.txt'

        assertFileContains folder.root, 'build.gradle', 'apply plugin: \'groovy\''
    }
}


================================================
FILE: src/test/groovy/templates/tasks/java/CreateJavaClassTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.java
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.java.CreateJavaClassTask.NEW_CLASS_NAME

class CreateJavaClassTaskTest extends AbstractTaskTester {

    CreateJavaClassTaskTest(){
        super( CreateJavaClassTask )
    }

    @Test void create(){
        project.apply plugin:'java'

        project.ext[NEW_CLASS_NAME] = 'foo.Something'

        task.create()

        assertFileContains folder.root, 'src/main/java/foo/Something.java', 'class Something'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/java/CreateJavaProjectTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.java
import org.junit.Test
import templates.AbstractTaskTester

class CreateJavaProjectTaskTest extends AbstractTaskTester {

    CreateJavaProjectTaskTest(){
        super( CreateJavaProjectTask )
    }

    @Test void create(){
        project.ext[CreateJavaProjectTask.PROJECT_PARENT_DIR] = folder.getRoot() as String
        project.ext[CreateJavaProjectTask.NEW_PROJECT_NAME] = 'tester'
        project.ext[CreateJavaProjectTask.PROJECT_GROUP] = 'test-group'
        project.ext[CreateJavaProjectTask.PROJECT_VERSION] = '1.1.1'

        task.create()

        assertFileExists folder.root, 'tester/src/main/java'
        assertFileExists folder.root, 'tester/src/main/resources'
        assertFileExists folder.root, 'tester/src/test/java'
        assertFileExists folder.root, 'tester/src/test/resources'
        assertFileExists folder.root, 'tester/LICENSE.txt'

        assertFileContains folder.root, 'tester/build.gradle', 'group = \'test-group\''
        assertFileContains folder.root, 'tester/gradle.properties', 'version=1.1.1'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/java/ExportJavaTemplatesTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.java

import org.junit.Test
import templates.AbstractTaskTester

class ExportJavaTemplatesTaskTest extends AbstractTaskTester {

    ExportJavaTemplatesTaskTest(){
        super( ExportJavaTemplatesTask )
    }

    @Test void export(){
        task.export()

        assertFileExists folder.root, 'templates/java/build.gradle.tmpl'
        assertFileExists folder.root, 'templates/java/java-class.tmpl'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/java/InitJavaProjectTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.java
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.java.AbstractJavaProjectTask.PROJECT_GROUP

class InitJavaProjectTaskTest extends AbstractTaskTester {

    InitJavaProjectTaskTest(){
        super( InitJavaProjectTask )
    }

    @Test void init(){
        project.ext[PROJECT_GROUP] = 'test-group'

        task.init()

        assertFileExists folder.root, 'src/main/java'
        assertFileExists folder.root, 'src/main/resources'
        assertFileExists folder.root, 'src/test/java'
        assertFileExists folder.root, 'src/test/resources'
        assertFileExists folder.root, 'LICENSE.txt'

        assertFileContains folder.root, 'build.gradle', 'apply plugin: \'java\''
    }
}


================================================
FILE: src/test/groovy/templates/tasks/scala/CreateScalaClassTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.scala.CreateScalaClassTask.NEW_CLASS_NAME

class CreateScalaClassTaskTest extends AbstractTaskTester {

    CreateScalaClassTaskTest(){
        super( CreateScalaClassTask )
    }

    @Test void create(){
        project.apply plugin:'scala'

        project.ext[NEW_CLASS_NAME] = 'foo.Something'

        task.create()

        assertFileContains folder.root, 'src/main/scala/foo/Something.scala', 'class Something'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/scala/CreateScalaObjectTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.scala.CreateScalaClassTask.NEW_CLASS_NAME

class CreateScalaObjectTaskTest extends AbstractTaskTester {

    CreateScalaObjectTaskTest(){
        super( CreateScalaObjectTask )
    }

    @Test void create(){
        project.apply plugin:'scala'

        project.ext[NEW_CLASS_NAME] = 'foo.Something'

        task.create()

        assertFileContains folder.root, 'src/main/scala/foo/Something.scala', 'object Something'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/scala/CreateScalaProjectTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.scala.AbstractScalaProjectTask.NEW_PROJECT_NAME
import static templates.tasks.scala.AbstractScalaProjectTask.PROJECT_GROUP
import static templates.tasks.scala.AbstractScalaProjectTask.PROJECT_PARENT_DIR
import static templates.tasks.scala.AbstractScalaProjectTask.PROJECT_VERSION
import static templates.tasks.scala.AbstractScalaProjectTask.SCALA_VERSION
import static templates.tasks.scala.AbstractScalaProjectTask.USE_FAST_SCALA_COMPILER

class CreateScalaProjectTaskTest extends AbstractTaskTester {

    CreateScalaProjectTaskTest(){
        super( CreateScalaProjectTask )
    }

    @Test
    void create(){
        project.ext[PROJECT_PARENT_DIR] = folder.getRoot() as String
        project.ext[NEW_PROJECT_NAME] = 'tester'
        project.ext[PROJECT_GROUP] = 'test-group'
        project.ext[PROJECT_VERSION] = '1.1.1'
        project.ext[SCALA_VERSION] = '2.9.0'
        project.ext[USE_FAST_SCALA_COMPILER] = true

        task.create()

        assertFileExists folder.root, 'tester/src/main/scala'
        assertFileExists folder.root, 'tester/src/main/resources'
        assertFileExists folder.root, 'tester/src/test/scala'
        assertFileExists folder.root, 'tester/src/test/resources'
        assertFileExists folder.root, 'tester/LICENSE.txt'

        assertFileContains folder.root, 'tester/build.gradle', 'scalaVersion = \'2.9.0\'', 'scalaCompileOptions.useCompileDaemon = true', 'group = \'test-group\''
        assertFileContains folder.root, 'tester/gradle.properties', 'version=1.1.1'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/scala/ExportScalaTemplatesTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala

import org.junit.Test
import templates.AbstractTaskTester
import templates.tasks.scala.ExportScalaTemplatesTask

class ExportScalaTemplatesTaskTest extends AbstractTaskTester {

    ExportScalaTemplatesTaskTest(){
        super( ExportScalaTemplatesTask )
    }

    @Test void export(){
        task.export()

        assertFileExists folder.root, 'templates/scala/build.gradle.tmpl'
        assertFileExists folder.root, 'templates/scala/scala-class.tmpl'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/scala/InitScalaProjectTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.scala
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.scala.AbstractScalaProjectTask.PROJECT_GROUP
import static templates.tasks.scala.AbstractScalaProjectTask.SCALA_VERSION
import static templates.tasks.scala.AbstractScalaProjectTask.USE_FAST_SCALA_COMPILER

class InitScalaProjectTaskTest extends AbstractTaskTester {

    InitScalaProjectTaskTest(){
        super( InitScalaProjectTask )
    }

    @Test void init(){
        project.ext[PROJECT_GROUP] = 'test-group'
        project.ext[SCALA_VERSION] = '2.9.0'
        project.ext[USE_FAST_SCALA_COMPILER] = true

        task.init()

        assertFileExists folder.root, 'src/main/scala'
        assertFileExists folder.root, 'src/main/resources'
        assertFileExists folder.root, 'src/test/scala'
        assertFileExists folder.root, 'src/test/resources'
        assertFileExists folder.root, 'LICENSE.txt'

        assertFileContains folder.root, 'build.gradle', 'scalaVersion = \'2.9.0\'', 'scalaCompileOptions.useCompileDaemon = true', 'group = \'test-group\''
        assertFileContains folder.root, 'gradle.properties', 'version=0.1'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/webapp/CreateWebappProjectTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.webapp
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.webapp.AbstractWebappProjectTask.NEW_PROJECT_NAME
import static templates.tasks.webapp.AbstractWebappProjectTask.PROJECT_GROUP
import static templates.tasks.webapp.AbstractWebappProjectTask.PROJECT_PARENT_DIR
import static templates.tasks.webapp.AbstractWebappProjectTask.PROJECT_VERSION
import static templates.tasks.webapp.AbstractWebappProjectTask.USE_JETTY_PLUGIN

class CreateWebappProjectTaskTest extends AbstractTaskTester {

    CreateWebappProjectTaskTest(){
        super( CreateWebappProjectTask )
    }

    @Test void 'create: jetty'(){
        project.ext[PROJECT_PARENT_DIR] = folder.getRoot() as String
        project.ext[NEW_PROJECT_NAME] = 'tester'
        project.ext[PROJECT_GROUP] = 'test-group'
        project.ext[PROJECT_VERSION] = '1.1.1'
        project.ext[USE_JETTY_PLUGIN] = 'y'

        task.create()

        assertFileExists folder.root, 'tester/src/main/java'
        assertFileExists folder.root, 'tester/src/main/resources'
        assertFileExists folder.root, 'tester/src/test/java'
        assertFileExists folder.root, 'tester/src/test/resources'
        assertFileExists folder.root, 'tester/LICENSE.txt'

        assertFileContains folder.root, 'tester/build.gradle', 'group = \'test-group\'', 'apply plugin: \'jetty\''
        assertFileContains folder.root, 'tester/gradle.properties', 'version=1.1.1'
    }

    @Test void 'create: war'(){
        project.ext[PROJECT_PARENT_DIR] = folder.getRoot() as String
        project.ext[NEW_PROJECT_NAME] = 'tester'
        project.ext[PROJECT_GROUP] = 'test-group'
        project.ext[PROJECT_VERSION] = '1.1.1'
        project.ext[USE_JETTY_PLUGIN] = 'n'

        task.create()

        assertFileExists folder.root, 'tester/src/main/java'
        assertFileExists folder.root, 'tester/src/main/resources'
        assertFileExists folder.root, 'tester/src/test/java'
        assertFileExists folder.root, 'tester/src/test/resources'
        assertFileExists folder.root, 'tester/LICENSE.txt'

        assertFileContains folder.root, 'tester/build.gradle', 'group = \'test-group\'', 'apply plugin: \'war\''
        assertFileContains folder.root, 'tester/gradle.properties', 'version=1.1.1'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/webapp/ExportWebappTemplatesTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.webapp

import org.junit.Test
import templates.AbstractTaskTester


class ExportWebappTemplatesTaskTest extends AbstractTaskTester {

    ExportWebappTemplatesTaskTest(){
        super( ExportWebappTemplatesTask )
    }

    @Test void export(){
        task.export()

        assertFileExists folder.root, 'templates/webapp/build.gradle.tmpl'
        assertFileExists folder.root, 'templates/webapp/web-xml.tmpl'
    }
}


================================================
FILE: src/test/groovy/templates/tasks/webapp/InitWebappProjectTaskTest.groovy
================================================
/*
 * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>
 * Copyright (c) 2013 Christopher J. Stehno <chris@stehno.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package templates.tasks.webapp
import org.junit.Test
import templates.AbstractTaskTester

import static templates.tasks.webapp.AbstractWebappProjectTask.PROJECT_GROUP
import static templates.tasks.webapp.AbstractWebappProjectTask.USE_JETTY_PLUGIN

class InitWebappProjectTaskTest extends AbstractTaskTester {

    InitWebappProjectTaskTest(){
        super( InitWebappProjectTask )
    }

    @Test void 'init: jetty'(){
        project.ext[PROJECT_GROUP] = 'test-group'
        project.ext[USE_JETTY_PLUGIN] = 'y'

        task.init()

        assertFileExists folder.root, 'src/main/java'
        assertFileExists folder.root, 'src/main/resources'
        assertFileExists folder.root, 'src/test/java'
        assertFileExists folder.root, 'src/test/resources'
        assertFileExists folder.root, 'LICENSE.txt'

        assertFileContains folder.root, 'build.gradle', 'apply plugin: \'jetty\''
    }

    @Test void 'init: war'(){
        project.ext[PROJECT_GROUP] = 'test-group'
        project.ext[USE_JETTY_PLUGIN] = 'n'

        task.init()

        assertFileExists folder.root, 'src/main/java'
        assertFileExists folder.root, 'src/main/resources'
        assertFileExists folder.root, 'src/test/java'
        assertFileExists folder.root, 'src/test/resources'
        assertFileExists folder.root, 'LICENSE.txt'

        assertFileContains folder.root, 'build.gradle', 'apply plugin: \'war\''
    }
}
Download .txt
gitextract_7j9h8z64/

├── .gitignore
├── LICENSE.txt
├── README.md
├── build.gradle
├── gradle.properties
├── installation/
│   ├── apply-local.groovy
│   └── apply.groovy
├── pom.xml
├── release.gradle
└── src/
    ├── main/
    │   ├── groovy/
    │   │   └── templates/
    │   │       ├── GradlePluginTemplatesPlugin.groovy
    │   │       ├── GroovyTemplatesPlugin.groovy
    │   │       ├── JavaTemplatesPlugin.groovy
    │   │       ├── ProjectTemplate.groovy
    │   │       ├── ScalaTemplatesPlugin.groovy
    │   │       ├── TemplatesPlugin.groovy
    │   │       ├── TemplatesPluginConvention.groovy
    │   │       ├── WebappTemplatesPlugin.groovy
    │   │       └── tasks/
    │   │           ├── AbstractProjectTask.groovy
    │   │           ├── AbstractTemplateExportTask.groovy
    │   │           ├── gradle/
    │   │           │   ├── AbstractGradleProjectTask.groovy
    │   │           │   ├── CreateGradlePluginTask.groovy
    │   │           │   ├── ExportPluginTemplatesTask.groovy
    │   │           │   └── InitGradlePluginTask.groovy
    │   │           ├── groovy/
    │   │           │   ├── AbstractGroovyProjectTask.groovy
    │   │           │   ├── CreateGroovyClassTask.groovy
    │   │           │   ├── CreateGroovyProjectTask.groovy
    │   │           │   ├── ExportGroovyTemplatesTask.groovy
    │   │           │   └── InitGroovyProjectTask.groovy
    │   │           ├── java/
    │   │           │   ├── AbstractJavaProjectTask.groovy
    │   │           │   ├── CreateJavaClassTask.groovy
    │   │           │   ├── CreateJavaProjectTask.groovy
    │   │           │   ├── ExportJavaTemplatesTask.groovy
    │   │           │   └── InitJavaProjectTask.groovy
    │   │           ├── scala/
    │   │           │   ├── AbstractScalaProjectTask.groovy
    │   │           │   ├── CreateScalaClassTask.groovy
    │   │           │   ├── CreateScalaObjectTask.groovy
    │   │           │   ├── CreateScalaProjectTask.groovy
    │   │           │   ├── ExportScalaTemplatesTask.groovy
    │   │           │   └── InitScalaProjectTask.groovy
    │   │           └── webapp/
    │   │               ├── AbstractWebappProjectTask.groovy
    │   │               ├── CreateWebappProjectTask.groovy
    │   │               ├── ExportWebappTemplatesTask.groovy
    │   │               └── InitWebappProjectTask.groovy
    │   └── resources/
    │       ├── META-INF/
    │       │   └── gradle-plugins/
    │       │       ├── gradle-plugin-templates.properties
    │       │       ├── groovy-templates.properties
    │       │       ├── java-templates.properties
    │       │       ├── scala-templates.properties
    │       │       ├── templates.properties
    │       │       └── webapp-templates.properties
    │       └── templates/
    │           ├── groovy/
    │           │   ├── build.gradle.tmpl
    │           │   └── groovy-class.tmpl
    │           ├── java/
    │           │   ├── build.gradle.tmpl
    │           │   └── java-class.tmpl
    │           ├── plugin/
    │           │   ├── build.gradle.tmpl
    │           │   ├── convention-class.tmpl
    │           │   └── plugin-class.tmpl
    │           ├── scala/
    │           │   ├── build.gradle.tmpl
    │           │   └── scala-class.tmpl
    │           └── webapp/
    │               ├── build.gradle.tmpl
    │               └── web-xml.tmpl
    └── test/
        └── groovy/
            └── templates/
                ├── AbstractTaskTester.groovy
                ├── GradlePluginTemplatesPluginTest.groovy
                ├── GroovyTemplatesPluginTest.groovy
                ├── JavaTemplatesPluginTest.groovy
                ├── ProjectTemplateTest.groovy
                ├── ScalaTemplatesPluginTest.groovy
                ├── TemplatesPluginTest.groovy
                ├── WebappTemplatesPluginTest.groovy
                └── tasks/
                    ├── gradle/
                    │   ├── CreateGradlePluginTaskTest.groovy
                    │   ├── ExportPluginTemplatesTaskTest.groovy
                    │   └── InitGradlePluginTaskTest.groovy
                    ├── groovy/
                    │   ├── CreateGroovyClassTaskTest.groovy
                    │   ├── CreateGroovyProjectTaskTest.groovy
                    │   ├── ExportGroovyTemplatesTaskTest.groovy
                    │   └── InitGroovyProjectTaskTest.groovy
                    ├── java/
                    │   ├── CreateJavaClassTaskTest.groovy
                    │   ├── CreateJavaProjectTaskTest.groovy
                    │   ├── ExportJavaTemplatesTaskTest.groovy
                    │   └── InitJavaProjectTaskTest.groovy
                    ├── scala/
                    │   ├── CreateScalaClassTaskTest.groovy
                    │   ├── CreateScalaObjectTaskTest.groovy
                    │   ├── CreateScalaProjectTaskTest.groovy
                    │   ├── ExportScalaTemplatesTaskTest.groovy
                    │   └── InitScalaProjectTaskTest.groovy
                    └── webapp/
                        ├── CreateWebappProjectTaskTest.groovy
                        ├── ExportWebappTemplatesTaskTest.groovy
                        └── InitWebappProjectTaskTest.groovy
Condensed preview — 87 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (146K chars).
[
  {
    "path": ".gitignore",
    "chars": 79,
    "preview": "build\n.gradle\n*.iml\n*.ipr\n*.iws\n.classpath\n.project\n.settings\n.idea\nout\nclasses"
  },
  {
    "path": "LICENSE.txt",
    "chars": 11359,
    "preview": "\n\n                                 Apache License\n                           Version 2.0, January 2004\n                 "
  },
  {
    "path": "README.md",
    "chars": 2786,
    "preview": "# Gradle Templates Plugin\n\n## Introduction\n\nThe Gradle Templates plugin helps you get started using Gradle by providing "
  },
  {
    "path": "build.gradle",
    "chars": 206,
    "preview": "apply plugin: 'groovy'\napply plugin: 'maven'\napply plugin: 'maven-publish'\n\nrepositories { mavenCentral() }\n\ndependencie"
  },
  {
    "path": "gradle.properties",
    "chars": 35,
    "preview": "group=gradle-templates\nversion=1.5\n"
  },
  {
    "path": "installation/apply-local.groovy",
    "chars": 835,
    "preview": "buildscript {\n\trepositories {\n\t\tivy {\n\t\t   String tpInstallDir = project.hasProperty('gradle.templates.dir') ? project.g"
  },
  {
    "path": "installation/apply.groovy",
    "chars": 390,
    "preview": "\nbuildscript {\n    repositories {\n        maven {\n            url 'http://dl.bintray.com/cjstehno/public'\n        }\n    "
  },
  {
    "path": "pom.xml",
    "chars": 1358,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n  ~ Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n  ~ Copyr"
  },
  {
    "path": "release.gradle",
    "chars": 1730,
    "preview": "apply plugin: 'groovy'\napply from: 'https://launchpad.net/gradle-release/trunk/latest/+download/apply.groovy'\n\nconfigura"
  },
  {
    "path": "src/main/groovy/templates/GradlePluginTemplatesPlugin.groovy",
    "chars": 1576,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/GroovyTemplatesPlugin.groovy",
    "chars": 1517,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/JavaTemplatesPlugin.groovy",
    "chars": 1917,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/ProjectTemplate.groovy",
    "chars": 6625,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/ScalaTemplatesPlugin.groovy",
    "chars": 1718,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/TemplatesPlugin.groovy",
    "chars": 3758,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/TemplatesPluginConvention.groovy",
    "chars": 966,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/WebappTemplatesPlugin.groovy",
    "chars": 1617,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/AbstractProjectTask.groovy",
    "chars": 3887,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/AbstractTemplateExportTask.groovy",
    "chars": 1884,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/gradle/AbstractGradleProjectTask.groovy",
    "chars": 3881,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/gradle/CreateGradlePluginTask.groovy",
    "chars": 1501,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/gradle/ExportPluginTemplatesTask.groovy",
    "chars": 1295,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/gradle/InitGradlePluginTask.groovy",
    "chars": 1148,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/groovy/AbstractGroovyProjectTask.groovy",
    "chars": 1584,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/groovy/CreateGroovyClassTask.groovy",
    "chars": 2896,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/groovy/CreateGroovyProjectTask.groovy",
    "chars": 1721,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/groovy/ExportGroovyTemplatesTask.groovy",
    "chars": 1228,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/groovy/InitGroovyProjectTask.groovy",
    "chars": 1261,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/java/AbstractJavaProjectTask.groovy",
    "chars": 1613,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/java/CreateJavaClassTask.groovy",
    "chars": 2934,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/java/CreateJavaProjectTask.groovy",
    "chars": 1712,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/java/ExportJavaTemplatesTask.groovy",
    "chars": 1238,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/java/InitJavaProjectTask.groovy",
    "chars": 1278,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/scala/AbstractScalaProjectTask.groovy",
    "chars": 2801,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/scala/CreateScalaClassTask.groovy",
    "chars": 3500,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/scala/CreateScalaObjectTask.groovy",
    "chars": 1249,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/scala/CreateScalaProjectTask.groovy",
    "chars": 1588,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/scala/ExportScalaTemplatesTask.groovy",
    "chars": 1211,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/scala/InitScalaProjectTask.groovy",
    "chars": 1176,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/webapp/AbstractWebappProjectTask.groovy",
    "chars": 2315,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/webapp/CreateWebappProjectTask.groovy",
    "chars": 1747,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/webapp/ExportWebappTemplatesTask.groovy",
    "chars": 1223,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/groovy/templates/tasks/webapp/InitWebappProjectTask.groovy",
    "chars": 1294,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/main/resources/META-INF/gradle-plugins/gradle-plugin-templates.properties",
    "chars": 58,
    "preview": "implementation-class=templates.GradlePluginTemplatesPlugin"
  },
  {
    "path": "src/main/resources/META-INF/gradle-plugins/groovy-templates.properties",
    "chars": 52,
    "preview": "implementation-class=templates.GroovyTemplatesPlugin"
  },
  {
    "path": "src/main/resources/META-INF/gradle-plugins/java-templates.properties",
    "chars": 50,
    "preview": "implementation-class=templates.JavaTemplatesPlugin"
  },
  {
    "path": "src/main/resources/META-INF/gradle-plugins/scala-templates.properties",
    "chars": 51,
    "preview": "implementation-class=templates.ScalaTemplatesPlugin"
  },
  {
    "path": "src/main/resources/META-INF/gradle-plugins/templates.properties",
    "chars": 46,
    "preview": "implementation-class=templates.TemplatesPlugin"
  },
  {
    "path": "src/main/resources/META-INF/gradle-plugins/webapp-templates.properties",
    "chars": 52,
    "preview": "implementation-class=templates.WebappTemplatesPlugin"
  },
  {
    "path": "src/main/resources/templates/groovy/build.gradle.tmpl",
    "chars": 91,
    "preview": "apply plugin: 'groovy'\n\ngroup = '${projectGroup}'\n\ndependencies {\n   groovy localGroovy()\n}"
  },
  {
    "path": "src/main/resources/templates/groovy/groovy-class.tmpl",
    "chars": 128,
    "preview": "package ${classPackage}\n\n/**\n * @author ${System.getProperty('user.name')}\n * Created: ${new Date()}\n */\nclass ${classNa"
  },
  {
    "path": "src/main/resources/templates/java/build.gradle.tmpl",
    "chars": 47,
    "preview": "apply plugin: 'java'\n\ngroup = '${projectGroup}'"
  },
  {
    "path": "src/main/resources/templates/java/java-class.tmpl",
    "chars": 171,
    "preview": "package ${classPackage};\n\n/**\n * @author ${System.getProperty('user.name')}\n * Created: ${new Date()}\n */\npublic class $"
  },
  {
    "path": "src/main/resources/templates/plugin/build.gradle.tmpl",
    "chars": 115,
    "preview": "apply plugin: 'groovy'\n\ngroup = '${projectGroup}'\n\ndependencies {\n   compile gradleApi()\n   groovy localGroovy()\n}\n"
  },
  {
    "path": "src/main/resources/templates/plugin/convention-class.tmpl",
    "chars": 138,
    "preview": "package ${classPackage}\n\n/**\n * @author ${System.getProperty('user.name')}\n * Created: ${new Date()}\n */\nclass ${classNa"
  },
  {
    "path": "src/main/resources/templates/plugin/plugin-class.tmpl",
    "chars": 374,
    "preview": "package ${classPackage}\n\nimport org.gradle.api.Project\nimport org.gradle.api.Plugin\n\n/**\n * @author ${System.getProperty"
  },
  {
    "path": "src/main/resources/templates/scala/build.gradle.tmpl",
    "chars": 631,
    "preview": "apply plugin: 'scala'\n\n<% if(projectGroup){ %>\ngroup = '${projectGroup}'\n<% } %>\n\nrepositories {\n\tmavenCentral()\n}\n\nscal"
  },
  {
    "path": "src/main/resources/templates/scala/scala-class.tmpl",
    "chars": 153,
    "preview": "package ${classPackage}\n\n/**\n * @author ${System.getProperty('user.name')}\n * Created: ${new Date()}\n */\n${object ? 'obj"
  },
  {
    "path": "src/main/resources/templates/webapp/build.gradle.tmpl",
    "chars": 92,
    "preview": "${useJetty ? 'apply plugin: \\'jetty\\'' : 'apply plugin: \\'war\\''}\n\ngroup = '${projectGroup}'"
  },
  {
    "path": "src/main/resources/templates/webapp/web-xml.tmpl",
    "chars": 595,
    "preview": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<!DOCTYPE web-app\n    PUBLIC \"-//Sun Microsystems, Inc.//DTD Web Application"
  },
  {
    "path": "src/test/groovy/templates/AbstractTaskTester.groovy",
    "chars": 2373,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/GradlePluginTemplatesPluginTest.groovy",
    "chars": 1264,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/GroovyTemplatesPluginTest.groovy",
    "chars": 1176,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/JavaTemplatesPluginTest.groovy",
    "chars": 1166,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/ProjectTemplateTest.groovy",
    "chars": 2684,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/ScalaTemplatesPluginTest.groovy",
    "chars": 1219,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/TemplatesPluginTest.groovy",
    "chars": 1939,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/WebappTemplatesPluginTest.groovy",
    "chars": 1129,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/gradle/CreateGradlePluginTaskTest.groovy",
    "chars": 2139,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/gradle/ExportPluginTemplatesTaskTest.groovy",
    "chars": 1222,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/gradle/InitGradlePluginTaskTest.groovy",
    "chars": 1752,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/groovy/CreateGroovyClassTaskTest.groovy",
    "chars": 1292,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/groovy/CreateGroovyProjectTaskTest.groovy",
    "chars": 1793,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/groovy/ExportGroovyTemplatesTaskTest.groovy",
    "chars": 1144,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/groovy/InitGroovyProjectTaskTest.groovy",
    "chars": 1470,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/java/CreateJavaClassTaskTest.groovy",
    "chars": 1230,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/java/CreateJavaProjectTaskTest.groovy",
    "chars": 1769,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/java/ExportJavaTemplatesTaskTest.groovy",
    "chars": 1130,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/java/InitJavaProjectTaskTest.groovy",
    "chars": 1454,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/scala/CreateScalaClassTaskTest.groovy",
    "chars": 1239,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/scala/CreateScalaObjectTaskTest.groovy",
    "chars": 1243,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/scala/CreateScalaProjectTaskTest.groovy",
    "chars": 2334,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/scala/ExportScalaTemplatesTaskTest.groovy",
    "chars": 1191,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/scala/InitScalaProjectTaskTest.groovy",
    "chars": 1869,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/webapp/CreateWebappProjectTaskTest.groovy",
    "chars": 3001,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/webapp/ExportWebappTemplatesTaskTest.groovy",
    "chars": 1140,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  },
  {
    "path": "src/test/groovy/templates/tasks/webapp/InitWebappProjectTaskTest.groovy",
    "chars": 2112,
    "preview": "/*\n * Copyright (c) 2011,2012 Eric Berry <elberry@tellurianring.com>\n * Copyright (c) 2013 Christopher J. Stehno <chris@"
  }
]

About this extraction

This page contains the full source code of the townsfolk/gradle-templates GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 87 files (130.8 KB), approximately 33.4k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!