Search code examples
mavengradlemaven-archetype

Gradle counterpart to Maven archetype?


What is the Gradle counterpart to Maven archetypes? How can I give other Gradle users a template for the file and directory layout for a new project?


Solution

  • Use build init plugin:

    ~$ mkdir newproj
    ~$ cd newproj
    ~/newproj$ gradle init --type java-library
    

    At the moment (May 2023, Gradle 8.1) the following types are supported:

    • pom
    • basic
    • java-application
    • java-gradle-plugin
    • java-library
    • kotlin-application
    • kotlin-gradle-plugin
    • kotlin-library
    • groovy-application
    • groovy-gradle-plugin
    • groovy-library
    • scala-application
    • scala-library