Create custom Build init type - for Gradle Build I

2020-08-12 03:47发布

问题:

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.

回答1:

  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.