Brewer Maven plugin
The Brewer Maven plugin helps you develop services. It is added to all generated services as a dependency.
Goals
The following goals are supported:
Name |
Type |
Description |
pre-deploy |
public |
Assert that the service exists in ApiOmat and create it if not |
download |
public |
Download and extract the service project |
download-with-swagger |
public |
Download and extract the service project generated from the given swagger.json definition |
updateVersion |
public |
Updates the generated service to a specific version (see parameters fromVersion and toVersion below for further details) |
add-dependency |
public |
Adds another used service as dependency to the generated service inclusive all needed configuration changes (see parameters serviceName and serviceVersion below for further details) |
write-metadata |
internal |
When generating a service, write some metadata for source merging to the service's META-INF folder |
Public goals are meant to be executed by users, while internal goals are only used for automatic processes, e.g. service generation
Configuration parameters
The following configuration parameters are supported for public goals only:
Name |
Description |
Supported by goal |
Supported values |
Example value |
host |
URL of your ApiOmat instance |
pre-deploy (required) |
|
|
brewerHost |
URL of your Brewer instance |
download (required), download-with-swagger |
|
|
system |
ApiOmat stage that should be used |
pre-deploy (required) |
LIVE, STAGING, TEST |
LIVE |
customerEmail |
Customer's email address (either this value or customerName is required) |
pre-deploy, download (all required) |
|
|
customerName |
Customer's login name (either this value or customerEmail is required) |
pre-deploy, download (all required) |
|
exampleCustomer |
customerPassword |
Customer's password |
pre-deploy, download (all required) |
|
secret |
serviceName |
ApiOmat service name |
all (required, see the additional notes below) |
|
TestService |
serviceVersion |
ApiOmat service version |
add-dependency (required) |
|
2.0.0 |
serviceDirectory |
directory to which the generated service will be downloaded to and unpacked in (default: new subfolder named after the generated service will be created in working directory) |
download-with-swagger |
|
|
swaggerDefDirectory |
directory of service defining swagger.json (default: working directory) |
download-with-swagger |
|
|
isServiceLib |
true if the processed Maven project is an ApiOmat service library |
all (see the additional notes below) |
true, false |
false |
merge |
Indicates whether the generated parts and the previously uploaded JAR should be merged, or only the generated parts should be returned |
download |
true, false |
true |
overwriteServicesImpl |
Whether to overwrite the local service's implementation files with the remote contents |
download |
true, false |
false |
overwriteAppConfigDefinition |
Whether to overwrite the local application's configuration definition file with the remote contents |
download |
true, false |
false |
overwriteTestFiles |
Whether to overwrite the local test files with the remote contents |
download |
true, false |
false |
brewerSkip |
Skip execution |
all |
true, false |
false |
fromVersion |
It is used as start version for the service update process. The full version number contains 4 digits for major version, minor version, hotfix version and patch version. If you use a shorter number, 0 will be used for the missing digits. E.g. 21.03 will be interpreted as 21.03.0.0 |
updateVersion |
|
20.11.0.0 |
toVersion |
used as target version for the service update process |
updateVersion |
|
21.03.0.0 |
withChangeLog |
enables writing a log file that contains all the changes of an service update (default: false) |
updateVersion |
true, false |
false |
Each parameter can be set via command line argument or in your personal Maven settings.xml file as part of a Maven profile (With the latter, you can encrypt the password for additional security):
<
settings
>
...
<
profiles
>
<
profile
>
<
id
>testing</
id
>
<
properties
>
<
host
>
https://your-yambas-instance.com
</
host
>
<
customerName
>john.doe</
customerName
>
</
properties
>
....
</
profile
>
....
</
profiles
>
...
</
settings
>
You can then activate this profile and use it within the build by appending -P testing.
Additional notes
-
WARNING: Note that due to Maven's nature, it is not possible to reload the POM within a Maven plugin (or within the entire Maven environment). Therefore, you have to be careful when combining goals that may modify the pom.xml with other goals or phases that are following afterwards.
The goals to be careful with is brewer:download. If you want to execute this goal followed by other ones, you have to execute the following goals as another command execution, like mvn brewer:download && mvn clean package . Thus, each command gets executed separately as own process and therefore the pom.xml will be re-read after the brewer:download
-
serviceName may be given, otherwise the plugin checks whether a name-tag is provided in the pom.xml, if there's none, it will try to find the service application main class and get the service name from the filename. At least, if this was unsuccessful, the artifactId gets used.
The serviceName parameter is mandatory for the brewer:add-dependency goal, because it is used to identify the name of the service that you want to add as dependency.
-
isServiceLib may be given, otherwise the plugin checks whether a name-tag is provided in the pom.xml and contains the "-lib"-suffix, if there's none, it will try to use the artifactId for determination. When everything was unsuccessful it uses false as default value.
-
either customerEmail or customerName has to be given for the supported goals, otherwise it will fail the build
-
note that the execution of a plugin goal does not include the full execution of maven phases. thus, if you execute the goal "brewer:pre-deploy", it will not automatically execute the compilation of your service (as it will only execute the single goal). but if you execute the maven phase "deploy" (and you've added the snippet of the general section below to your pom.xml), it will execute the "brewer:pre-deploy" goal within the "verify" phase and create the service in your configured ApiOmat instance if it does not exist yet.
-
the download-with-swagger goal will first check the swaggerDefDirectory for a swagger.json then downloads and unpacks the generated service to the serviceDirectory
Examples
Following snippet will show you how you will use this plugin.
General
After adding the plugin to the pom.xml of the service, you simply call it over mvn brewer:<goalName> instead of calling mvn com.apiomat.helper:brewer-maven-plugin:<goalName>
1. Add the following snippet to your pom.xml:
<
project
>
...
<
build
>
...
<
plugins
>
...
<
plugin
>
<
groupId
>com.apiomat.helper</
groupId
>
<
artifactId
>brewer-maven-plugin</
artifactId
>
<
version
>0.0.1-SNAPSHOT</
version
>
</
plugin
>
</
plugins
>
</
build
>
</
project
>
2. Execute the following command to download your service
mvn clean package brewer:download -DcustomerName=<yourCustomerName> -DcustomerPassword=<yourCustomerPassword> -Dhost=<yourYambasHost> -DbrewerHost=<yourBrewerHost>
Updating your generated Service
The steps you need to follow to update your generated service are detaily described in Update your Service to the current version.
Adding a used Service Dependency
Follow the detailed step by step guide in the article about Using other Services > Setting Used Service Relation > Option A) Automatic via Brewer-Maven-Plugin.