Giter Site home page Giter Site logo

gradle-templates's Introduction

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:

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 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 page.

Details

Build Status

gradle-templates's People

Contributors

cjstehno avatar merscwog avatar polopi avatar townsfolk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gradle-templates's Issues

Unable to execute initScalaProject task

Hi,
I am trying to initialize a Scala Project within a directory.
Gradle excetution of 'initScalaProject' fails with an exception.

I have provided the stack execution and results below:
$ gradle initScalaProject

Building > :initScalaProject
??> Scala Version: [2.9.0] y

??> Use fast compiler? (Y|n) y
:initScalaProject FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':initScalaProject'.

    Could not find property 'projectGroup' on root project 'SimpleScalaProject'.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 12.592 secs

DefaultValue in promptOptions cause error

See also #20 #21
The method request an int as defaultValue value

static int promptOptions(String message, int defaultValue, List options = [])

then in readLine, it returns the int

return System.console().readLine(_message) ?: defaultValue

and then tries to call parseInt on it

int choice = Integer.parseInt(readLine(consoleMessage, defaultValue))

Finally you end up with that kind of error :
No signature of method: static java.lang.Integer.parseInt() is applicable for argument types: (java.lang.Integer) values: [0]

Convert to standardized license?

Any chance you could convert this project to a more standardized license like Apache 2 or something? What you have is flexible enough but being non-standard it may deter some users.

I would be willing to make the conversion and submit a pull request.

Allow installation of core only

In some use cases we may only want the core templates functionality without any of the technology-specific derivatives. It would be nice to be able to just pull in the core as a plugin without the other parts - similar to how you could just install the java-templates plugin now.

setupBuild --type

Do templates relate at all to gradle's setupBuild --type option? (other than offering many more templates)

PromptOptions display prompt twice

The issue comes from there in src/main/groovy/templates/TemplatesPlugin.groovy

String consoleMessage = "${inputPrompt} ${message}"

And then when calling readLine(String message, def defaultValue = null) with previous consoleMessage

String _message = "$inputPrompt $message " + (defaultValue ? "[$defaultValue] " : "")

Does not work with Gradle 4.0.7

My build.gradle looks like this

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

apply plugin:'templates'

If I execute gradle createJavaProject, the following error occurs:

A problem occurred evaluating root project 'template-interfaces'.
> Failed to apply plugin [class 'templates.GroovyTemplatesPlugin']
   > Could not create task of type 'CreateGroovyClassTask'.

Create tests with classes

For tasks that create a class or classes, appropriate unit tests should also (optionally?) be created.

Installation from source

I'm having trouble installing this plugin from source. Are the directions still accurate? I'm on gradle 1.3. I forked and cloned the repo, then ran gradle build which ran successfully. Then I created a new folder with a blank build.gradle and added the following lines:

apply plugin: 'groovy'
apply from: 'file:///Users/kboon/Documents/workspace/gradle-templates/installation/apply-local.groovy'

I also copied templates-1.3.jar into my gradlehome/lib directory. The error I am seeing is:

AILURE: Build failed with an exception.

  • Where:
    Build file '/Users/kboon/Documents/workspace/gradle-templates-test/build.gradle' line: 2

  • What went wrong:
    A problem occurred evaluating root project 'gradle-templates-test'.

    Could not resolve all dependencies for configuration 'classpath'.
    Could not find group:gradle-templates, module:templates, version:unspecified.
    Required by:
    unspecified:unspecified:unspecified

This is the first time I've tried to install a gradle plugin from source so this could just be my fault. Thanks for any help.

Create a GitHub pages site for project

I don't have enough project privileges to create a GitHub pages for the project. Please create the main template and I can fill in the details - Thanks.

Layered and/or mixin approach to templates

Would be interesting/useful to allow templates (or partial templates) to be merged to create a project or fileset (or added to an existing project)... say I want to create a java project based on maven you could apply the java templates and maven templates, and when I want a java+gradle project you could apply the java and gradle templates.

Not sure how to do this yet, but it could be a nice addition. This may already exist functionally so perhaps only documentation is needed.

PromptOptions display defaultValue twice

Same root cause as #20

if (defaultValue) {
    consoleMessage += "${inputPrompt} [${defaultValue}] "
} else {
    consoleMessage += "${inputPrompt} "
}

and again in readLine(String message, def defaultValue = null) with the previous consoleMessage

String _message = "$inputPrompt $message " + (defaultValue ? "[$defaultValue] " : "")

Creating own project templates

Hi,

I tried installing the plugin using the binary option and I was able to run gradle createJavaProject successfully.
I tried the sample build which is used to create a simple custom project structure .

When I run gradle createMyProject , i get the below error.

gradle createMyProject
:createMyProject FAILED

FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users//Desktop/sample_projects/try_out_gradle_templates/build.gradle' line: 5

  • What went wrong:
    Execution failed for task ':createMyProject'.

    Could not find property 'TemplatesPlugin' on task ':createMyProject'.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 16.004 secs

Please guide.

Add license template options

It would be useful to provide template options to inject one of the more common licenses into the project rather than the empty file.

Setup Drone.io Build for project

I don't have permissions to add commit hooks to the repository so I cannot setup a Drone.io build. I will see if there is a work-around otherwise I may need some admin assistance.

Is this project still maintained?

I'm asking because I'm having a project which uses this and we're having issues when we tried to use this with gradle 3.1. I'm willing to fix that but I need to know if anyone will review/merge/release it.

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

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

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

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

  • D3 photo D3

    Data-Driven Documents codes.