Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create custom Build init type - for Gradle Build Init Plugin?

I'm fairly new to gradle and I would like to create a custom type for with the Gradle Init Plugin. Moreover, I'd like to be able to do something like:

gradle init --type jsp-library

This would generate a project directory with the same structure as a Java web application (webapp, stylesheets, etc...). Yes, I have read this, and I know that only a limited amount of types are available. I just want to know if someone has or knows of some sort of work around for the time being.

like image 231
coderrick Avatar asked Jan 18 '16 14:01

coderrick


People also ask

How do I add plugins to build Gradle?

To add a Gradle plugin with dependencies, you can use code similar to the following: Plugin DSL GA versions. Plugin DSL non GA versions. Legacy Plugin Application.

How do you init a Gradle project?

From inside the new project directory, run the init task using the following command in a terminal: gradle init . When prompted, select the 2: application project type and 3: Java as implementation language. Next you can choose the DSL for writing buildscripts - 1 : Groovy or 2: Kotlin .

What is subprojects in Gradle?

The subproject producer defines a task named buildInfo that generates a properties file containing build information e.g. the project version. You can then map the task provider to its output file and Gradle will automatically establish a task dependency.


1 Answers

  1. There are 3rd party plugins that allow you to create custom templates and generate new projects from templates. For instance, see: https://github.com/townsfolk/gradle-templates

  2. Use maven to generate a project from archetype and then use gradle init to convert it to gradle project.

  3. Modify the init plugin yourself from source to add more init types.

like image 67
RaGe Avatar answered Oct 10 '22 18:10

RaGe