Gradle counterpart to Maven archetype?

MavenGradleMaven Archetype

Maven Problem Overview


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?

Maven Solutions


Solution 1 - Maven

Use [build init plugin][1]:

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

At the moment java-library, scala-library, groovy-library, java-application, pom and basic supported. The feature is incubating, thus it can be changed in future releases, so keep an eye on docs. [1]: http://www.gradle.org/docs/current/userguide/build_init_plugin.html

Solution 2 - Maven

Gradle doesn't support this (yet). There's a open feature request opened already.

Solution 3 - Maven

There is no gradle counterpart as far as I know. However following the steps given below is enough for most cases:

  • Generate project with maven and your selection of maven archetype.
  • Convert the maven project to gradle project. You can do that by executing the below command in the directory where your master pom.xml is located:
    gradle init
    

It is supposed to work with all basic maven archetypes.

Solution 4 - Maven

While this is not yet supported by Gradle, the gradle:templates plugin looks promising:

Solution 5 - Maven

Gradle don't support build-in archetype-like feature, but you can use plug-in named Gradle templates

Read more:
Does gradle have Maven archetype-like functionality?
Gradle archetypes issue

Solution 6 - Maven

I'm been looking for this feature as well, and found that it's a little bit complicated to have a complex project template to work with https://github.com/townsfolk/gradle-templates.

So I created this plugin, it's quite similar with the Maven archetype function. https://github.com/orctom/gradle-archetype-plugin/

Solution 7 - Maven

In case you are using the spring framework under Linux: You could use http://start.spring.io/ or alternatively install Spring CLI

$ curl -s "https://get.sdkman.io" | bash

$ sdk install springboot

$ spring --version
Spring Boot v1.3.5.RELEASE

$ spring init --build gradle --name test --groupId com.test
Using service at https://start.spring.io
Content saved to 'demo.zip'

$ unzip demo.zip 

Solution 8 - Maven

You can create generators for Yeoman, or use existing non-official ones such as JHipster. As an example there is the java-gradle generator:

> 1. npm install -g yo > 2. Install module globally: npm install -g generator-java-gradle > 3. Generate project with: yo java-gradle

Solution 9 - Maven

Looks like solution is available now: https://plugins.gradle.org/plugin/com.orctom.archetype

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondeamonView Question on Stackoverflow
Solution 1 - Mavenpavel_kazlouView Answer on Stackoverflow
Solution 2 - MavenJB NizetView Answer on Stackoverflow
Solution 3 - MavenTevfik KizilorenView Answer on Stackoverflow
Solution 4 - MavenDavid ResnickView Answer on Stackoverflow
Solution 5 - MavenJames GrahamView Answer on Stackoverflow
Solution 6 - MavenHaoView Answer on Stackoverflow
Solution 7 - MavenYordan NedelchevView Answer on Stackoverflow
Solution 8 - MaventkruseView Answer on Stackoverflow
Solution 9 - Mavenf-z-NView Answer on Stackoverflow