Gradle counterpart to Maven archetype?

后端 未结 9 1288
情书的邮戳
情书的邮戳 2020-12-13 12:19

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?

相关标签:
9条回答
  • 2020-12-13 12:40

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

    0 讨论(0)
  • 2020-12-13 12:44

    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

    0 讨论(0)
  • 2020-12-13 12:46

    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.

    0 讨论(0)
  • 2020-12-13 12:46

    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 
    
    0 讨论(0)
  • 2020-12-13 12:47

    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/

    0 讨论(0)
  • 2020-12-13 12:49

    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
    0 讨论(0)
提交回复
热议问题