Introduction

Click here to start using the Meta-Template.

The Meta-Template BootHub template lets you create BootHub templates.

It allows you to customize the created template in accordance with the type of projects you intend to generate with it. The project features you can opt for while configuring the created template include:

  • the ability to produce Maven-compatible artifacts

  • software license support

  • project versioning support

  • support for gradle-based projects

  • support for single-module projects, multi-module projects or both

  • support for libraries, applications or both

  • Bintray upload support

The source code is available on GitHub and is licensed under the Apache-2.0 license.

Getting Started

You can generate a template skeleton based on the Meta-Template BootHub template by using the BootHub GUI or the BootHub CLI.

After providing the template-independent data, you need to configure the template-ID and provide a short description of your template:


Template ID [com.github.my-template]:
Short description: A BootHub template for my side projects.


Then you need to specify whether the projects generated by your template will produce Maven-compatible artifacts:


Is your template intended to be used for generating projects that produce Maven-compatible artifacts? (Y/N) [Y]:


Usually, only projects written in a JVM language can produce Maven-compatible artifacts. For all other project types your answer to the above question should be N, in which case you need to specify if the generated projects require license and versioning support:


Should your template require a license for the generated projects? (Y/N) [Y]:
Should your template require project versioning? (Y/N) [Y]:


If your projects should generate Maven-compatible artifacts, the meta-template automatically configures support for licensing and project versioning, but you need to answer additional questions regarding the template you want to create:


Is your template intended to be used for generating gradle-based projects? (Y/N) [Y]:


If you opt for gradle-based projects, the generated template is able to create gradle build scripts customized in accordance with the answers you provide to the subsequent questions.


Should the gradle script of the projects generated by your template provide support for publishing artifacts to Bintray? (Y/N) [Y]:


If you opt for Bintray support, the gradle scripts created by your template will provide the bintrayUpload task, which allows you to publish artifacts to Bintray.

Then, you need to specify the structure of the generated projects:


What kind of structure should have the projects generated by your template?
  1: Only single-module projects
  2: Only multi-module projects
  3: Both single-module and multi-module projects
Enter your choice:


The final piece of information you need to provide concerns the type of projects your template will create:


What type of projects should your template generate?
  1: Only applications (the generated projects will provide a main class)
  2: Only libraries (the generated projects will not provide a main class)
  3: Both applications and libraries (the generated projects may or may not provide a main class)
Enter your choice:


User Guide

After generating the template skeleton and creating a working copy on your computer, you can start customizing it.

Read about writing BootHub templates before editing your template.

The contextClass used by the generated template (as configured in skeleton/template/config.yml) is named MainContext and can be found in the skeleton/template/script/<package-dir>/context directory, where <package-dir> and the package of MainContext match the ID of your template.

Gradle-based template skeletons provide a sample trait called InfoContext, which is implemented by MainContext. This trait configures a sample property named myExampleProperty.

Change the provided context classes according to your needs. Typically, this means replacing the sample property with properties required by your template and providing the appropriate configuration code. Feel free to rename the InfoContext trait according to your needs and to create additional traits if necessary.

If your template doesn’t require any properties, you can delete the InfoContext.groovy file and remove any references to this trait in MainContext.groovy.

Place the files needed by your template in the skeleton/template/files and skeleton/template/files-src directories, as described in the tutorial about writing BootHub templates.

For gradle-based template skeletons, a Spock specification is available in the src/test/groovy directory. Change it according to your needs, by editing the existing tests and adding new ones. Also, consider using a ProjectContextStreamBuilder to perform tests with all combinations of flags (that is, boolean or enum properties provided by your template).

Before publishing your template, you should execute it locally to check that everything looks good. You can do this by running the BootHub CLI with a SingleSkeletonRepo, either from your IDE or using a locally-installed CLI:

  • from your IDE: create a run configuration with org.boothub.BootHubCli as main class and the following VM options:
    -DboothubRepoClass=org.boothub.repo.SingleSkeletonRepo -DboothubRepoPath=<your-template-directory>/skeleton

  • using a locally-installed BootHub-CLI: set the environment variable
    BOOTHUB_OPTS=-DboothubRepoClass=org.boothub.repo.SingleSkeletonRepo -DboothubRepoPath=<your-template-directory>/skeleton

Developer Guide

This section is for developers who want to fix bugs or change the functionality of the Meta-Template BootHub template.

Read about writing BootHub templates before starting to change the Meta-Template BootHub template.

The Meta-Template BootHub template comes with a suite of tests that generate various skeletons and check their validity. You should update these tests and add new ones according to the changes you make.

Command Line Build

The Meta-Template BootHub template is built with Gradle and requires JDK 8 or higher. Clone the GitHub repository, cd into the top directory and start the build:

git clone https://github.com/boothub-org/boothub-meta-template.git
cd boothub-meta-template
./gradlew clean build            (On Windows: gradlew clean build)

IntelliJ Idea

  • start the IntelliJ Idea IDE

  • open build.gradle

Eclipse

  • start the Eclipse IDE

  • install a recent version of Buildship

  • import the project using the Gradle Project wizard