. . .

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

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

serviceName

ApiOmat service name

all (required, see the additional notes below)

TestService

host

URL of your ApiOmat instance

all (required)

http://localhost:8080

brewerHost

URL of your Brewer instance

download (required)

http://localhost:8180

system

ApiOmat stage that should be used

pre-deploy (required)

LIVE, STAGING, TEST

LIVE

customerEmail

Customer's email address

all (either this value or customerName required)

customer@example.com

customerName

Customer's login name

all (either this value or customerEmail required)

exampleCustomer

customerPassword

Customer's password

all (required)

secret

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

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.xml
<settings>
...
<profiles>
<profile>
<id>testing</id>
<properties>
<host>https://your-yambas-instance.com</host>
<customerName>john.doe</customerName>
<customerPassword>dont_panic</customerPassword>
</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 with other goals or phases that come after.
    So if you want to execute brewer:download followed by other goals, you have to execute the other goals as a separate command, e.g. mvn brewer:download && mvn clean package. As each command is executed as a separate process, the POM will be reloaded after brewer:download.

  • If serviceName is not given, the plugin checks whether a name tag is provided in the POM. If there isn't one, it will try to find the service's main application class and get the service name from the class's filename. If this is also unsuccessful, the artifact ID is used.

  • Either customerEmail or customerName has to be given when executing goals, otherwise the build will fail.

  • The execution of a plugin goal does not include the full execution of Maven phases. So if you execute the goal brewer:pre-deploy, it will not automatically compile your service (as it will only execute the single goal).
    But if you execute the Maven phase deploy, it will execute the brewer:pre-deploy goal within the verify phase.

Examples

The following snippet will show you how to use this plugin.

General

In your service, you can simply call the plugin with mvn brewer:<goalName> instead of calling mvn com.apiomat.helper:brewer-maven-plugin:<goalName>This is because of the following snippets in your service's pom.xml:

pom.xml
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>com.apiomat.helper</groupId>
<artifactId>brewer-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
...
<pluginRepositories>
<pluginRepository>
<id>easynexus</id>
<url>https://nexus.easy.de/repository/maven-public-all/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
...
</project>

So to download your service, you can simply execute the following command:

mvn clean package brewer:download -DcustomerName=<yourCustomerName> -DcustomerPassword=<yourCustomerPassword> -Dhost=<yourYambasHost> -DbrewerHost=<yourBrewerHost>