A JHipster module is a Yeoman generator that is composed with a specific JHipster sub-generator.
JHipster modules are listed on the JHipster marketplace.
This allows to create third-party generators that have access to the JHipster variables and functions, and act as standard JHipster sub-generators.
The JHipster Fortune module generates a “fortune cookie” page in a JHipster-generated application.
It is our sample module that showcases how you can JHipster’s variables and functions in order to create your own generator.
A JHipster module:
A JHipster module uses the new “composability” feature from Yeoman, described at http://yeoman.io/authoring/composability.html to have access to JHipster’s variables and functions.
For this, it composes with the “jhispter:modules” sub generator:
templates: function() {
this.composeWith('jhipster:modules', { options: {
jhipsterVar: jhipsterVar, jhipsterFunc: jhipsterFunc }});
},
Global variables:
baseName
: the name of the applicationpackageName
: the Java package nameangularAppName
: the AngularJS application namejavaDir
: the directory for the Java application, including the package foldersresourceDir
: the directory containing the Java resources (always src/main/resources
)webappDir
: the directory containing the Web application (always src/main/webapp
)And all the variables from your .yo-rc.json
file:
authenticationType
: the type of authenticationhibernateCache
: the Hibernate 2nd level cacheclusteredHttpSession
: whether a clustered HTTP session is usedwebsocket
: whether WebSockets are useddatabaseType
: the type of database useddevDatabaseType
: the database used in “dev” modeprodDatabaseType
: the database used in “prod” modesearchEngine
: whether a search engine is useduseSass
: if Sass is used for CSS pre-processingbuildTool
: the Java build toolfrontendBuilder
: the front-end (JavaScript/CSS/HTML) build toolenableTranslation
: if translations are enabledenableSocialSignIn
: if social login is enabledtestFrameworks
: an array of the test frameworks selectedaddJavaScriptToIndex
: add a JavaScript file to the index.html
addMessageformatLocaleToIndex
: add a message format locale (for i18n)addElementToMenu
: add an entry in the navigation menuaddEntityToMenu
: add an entity in the entity navigation sub-menuaddElementTranslationKey
: add a new translation key in the global.json
fileaddEntityTranslationKey
: add a new translation key for an entity in the global.json
fileaddChangelogToLiquibase
: add a new changelog in the Liquibase master.xml
filedateFormatForLiquibase
: creates a new timestamp to be used by a Liquibase changelogcopyI18nFilesByName
: copy i18n filesTo have your module available in the JHipster marketplace, you need to add it to the modules.json file by doing a Pull Request to the jhipster/jhipster.github.io project.
The modules.json
is a JSON file containing an array of the available modules. Add a new module in the array, and specify all fields. Leave the “verified” field as false: your module will become “verified” if the JHipster team verifies it.
Once your Pull Request is accepted, your module will become available!