grails create-plugin [OPTIONS] NAME
create-plugin
Description
The create-plugin
command is used to create a Grails plugin project. A Grails plugin project is similar to an application project but includes a plugin descriptor and can be packaged as a plugin to be installed into other Grails applications.
Plugins are not only valuable for plugin developers but also serve as a means to modularize large Grails applications. They allow you to encapsulate functionality and easily reuse it across different projects. To learn more about developing plugins for Grails, refer to the section on Plugin Development in the Grails user guide.
Usage
To create a Grails plugin, use the following command:
-
NAME
: The desired name for the Grails plugin.
Options include specifying features, configuring the GORM implementation, selecting a servlet implementation, choosing a test framework, setting the JDK version, and more. You can tailor your Grails plugin to your specific requirements using these options.
Options
Here are the available options for the create-plugin command:
-
-f, --features=FEATURE[,FEATURE…]: Specifies the features to include in the plugin. Available options include h2, gorm-hibernate5, spring-boot-starter-jetty, springloaded, micronaut-http-client, cache-ehcache, hibernate-validator, postgres, mysql, cache, database-migration, grails-gsp, hamcrest, gorm-mongodb, assertj, mockito, spring-boot-starter-undertow, micronaut-inject-groovy, github-workflow-java-ci, jrebel, testcontainers, sqlserver, grails-console, views-markup, views-json, gorm-neo4j, asciidoctor, embedded-mongodb, grails-web-console, logbackGroovy, mongo-sync, shade, properties.
-
-g, --gorm=GORM Implementation: Specifies the GORM Implementation to configure for the plugin. Possible values are hibernate, mongodb, neo4j.
-
-h, --help: Displays the help message and exits.
-
-i, --inplace: Creates a service within the current directory.
-
--jdk=<javaVersion>: Specifies the JDK version the project should target.
-
-s, --servlet=Servlet Implementation: Specifies the Servlet Implementation to configure for the plugin. Possible values are none, tomcat, jetty, undertow.
-
-t, --test=TEST: Specifies the test framework to use for the plugin. Possible values are junit, spock.
Examples
To create a Grails plugin named "example-plugin" with specific features:
grails create-plugin example-plugin --features h2,gorm-hibernate5,asciidoctor
This command will generate a Grails plugin project named "example-plugin" with the specified features, making it ready for development and integration into other Grails applications.
Here are additional examples for the create-plugin
command:
-
Create a minimal Grails plugin:
grails create-plugin minimal-plugin
This command will create a Grails plugin project named "minimal-plugin" with the default settings, suitable for starting a new plugin project from scratch.
-
Create a plugin with MongoDB support:
grails create-plugin mongodb-plugin --gorm=mongodb
This command will generate a Grails plugin project named "mongodb-plugin" configured to use MongoDB as the GORM implementation.
-
Create a plugin with embedded H2 database and view support:
grails create-plugin h2-views-plugin --features h2,views-markup
This command will create a Grails plugin project named "h2-views-plugin" with the H2 database and views markup feature enabled, making it useful for projects that require an embedded database and view rendering capabilities.
These additional examples showcase different use cases for the create-plugin
command, such as creating minimal plugins, customizing GORM implementations, and enabling specific features to meet project requirements.