The Maven Plugin for API Gateway requires the installation of the Package & Deployment Tools of the Axway API Gateway. If you want to edit the projects PolicyStudio has to be installed also. Please checkout the Axway documentation on how to install the software.
It is recommended to install the tools under the same directory. This directory is used by the plugin as the Axway Home directory.
[folder] axway-home [folder] apigateway [folder] policystudio
It is required to configure the Axway Home directory by specifying the property axway.home
.
Due to the location is individual for each developer, configure the property in your personal ~/.m2/settings.xml
file.
<settings
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"
>
<profiles>
<profile>
<id>axway</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<axway.home>c:/axway</axway.home> <!--(1)-->
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>axway</activeProfile>
</activeProfiles>
</settings>
-
Specify the location of your Axway installation here.
Alternatively the Axway home directory can be specified via the -D
option of Maven command:
$ mvn -Daxway.home=c:/axway package
To setup a new API Gateway project, create an empty folder and create a Maven pom.xml
file.
Set the desired packaging type and add the API Gateway plugin (see below).
Following packaging types are supported:
-
axway-policy-archive
-
axway-server-archive
-
axway-deployment-archive
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<!-- ... -->
<packaging>axway-policy-archive</packaging> <!--(1)-->
<build>
<plugins>
<plugin> <!--(2)-->
<groupId>com.axway.maven.plugins</groupId>
<artifactId>apigw-maven-plugin</artifactId>
<version>{mvn-plugin-ver}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
-
The packing type
axway-policy-archive
marks it as a policy project. Other packaging types available. -
Use Maven Plugin for API Gateway for this project.
To initialize the project invoke the following command in your project directory:
$ mvn apigw:init
According to your packaging type the project is initialized with a default directory structure and a default project template.
If your project requires policies from other project, add the according dependencies to your pom.xml
file.
<dependencies>
<dependency> <!--(1)-->
<groupId>com.example</groupId>
<artifactId>common</artifactId>
<version>1.0.0</version>
<type>axway-policy-archive</type> <!--(2)-->
</dependency>
</dependencies>
-
Add the dependency.
-
Set the packaging type of the dependent artifact.
To edit the project just invoke the goal apigw:policystudio
.
$ mvn apigw:policystudio
📎
|
If PolicyStudio is started the first time in the project directory it has to be initialized first. In this case you will be prompted to close PolicyStudio right after startup.
So, just close PolicyStudio and invoke the Maven goal |
This will download all dependent projects, configure the dependencies and will start PolicyStudio. For convenience the recently used projects are preset to your project. So just click on the links.
To ensure that the latest version of dependent projects are used use the apigw:policystudio
goal in combination with the clean
goal.
$ mvn clean apigw:policystudio
📎
|
As Deployment Projects don’t have policies to be edited, the goal is not supported for projects of packaging type |
All artifacts and temporarily files are generated in the target
folder.
Use the goal clean
to delete the target folder and to cleanup all generated artifacts.
$ mvn clean
To build the project artifacts use the package
goal.
$ mvn clean package
This will build the projects archives (policy archive, server archive or deployment archive) depending on the project type.
To install the project to a gateway instance the goal apigw:deploy
is used.
It only supports a standard deployment.
Deployment of static files or JARs are not supported.
For deployment following properties are used:
Property | Description | Mandatory |
---|---|---|
|
Host of the Admin Node Manager. |
yes |
|
Port of the Admin Node Manager (default: 8090). |
no |
|
User to connect to the Admin Node Manager (default: admin). |
no |
|
Password of the user. |
yes |
|
Name of the group the project is deployed to. |
yes |
|
Passphrase for |
no |
|
Passphrase for |
no |
|
Passphrase for deployment group. |
no |
|
Path to environmentalized fields configuration file. |
yes |
|
Path to certificates configuration file. |
no |
|
Path to properties configuration file. |
no |
|
Comma separated list of paths to properties configuration files. |
no |
|
Path to secrets file. |
no |
|
Path to key file to decrypt/encrypt values of secrets file. |
yes, if secrets file is specified |
Example:
$ mvn -Daxway.anm.host=localhost -Daxway.anm.password=changeme -Daxway.deploy.group=test -Daxway.config.envs=gateway.config.json clean apigw:deploy
For policy projects the test server which is included in the project is deployed.
Steps:
-
Execute
package
lifecycle. -
Build
.pol
and.env
packages. -
Build and configure
.fed
package. -
Deploy
.fed
package to gateway
For server projects the generated .pol
and .env
packages are deployed.
Steps:
-
Execute
package
lifecycle. -
Build and configure
.fed
package from.pol
and.env
packages. -
Deploy
.fed
package to gateway
The location of configuration files can be specified via the <configuration> element of the plugin or via Maven properties or via the -D
parameter of the Maven command line.
<!- ... ->
<plugin>
<groupId>com.axway.maven.plugins</groupId>
<artifactId>apigw-maven-plugin</artifactId>
<version>{mvn-plugin-ver}</version>
<extensions>true</extensions>
<configuration>
<configConfigFile>${basedir}/src/main/axwgw/gateway.config.json</configConfigFile> <!--(1)-->
</configuration>
</plugin>
<!- ... ->
-
Location of the configuration file for environmentalized fields.
$ mvn package -Daxway.config.envs=gateway.config.json
<!- ... ->
<plugin>
<groupId>com.axway.maven.plugins</groupId>
<artifactId>apigw-maven-plugin</artifactId>
<version>{mvn-plugin-ver}</version>
<extensions>true</extensions>
<configuration>
<configCertsFile>${basedir}/src/main/axwgw/gateway.certs.json</configCertsFile> <!--(1)-->
</configuration>
</plugin>
<!- ... ->
-
Location of the configuration file for certificates.
$ mvn package -Daxway.config.certs=gateway.certs.json
The Maven plugin supports three options to specify configuration properties:
-
Embedded in the configuration files for environmentalized fields or for certificates.
-
Via a configuration file specified by the property
axway.config.props
or via the <configPropertyFile> element in the <configuration> element of the plugin. This is the master configuration file. -
Via configuration files specified by the <configPropertyFiles> element in the <configuration> element of the plugin.
-
Via configuration files specified by a comma separated list of the property
axway.config.props.files
. These are called the additionally configuration files.
Properties are read in the order listed above. If a property exists in multiple configuration files the value of the latest configuration file is used.
For deployment projects, the location of the mandatory configuration file for environmentalized fields is implicitly set to ${basedir}/src/main/axwgw/gateway.config.json
.
The file will be created during the initialization of the project (goal apigw:init
).
The location of the configuration files can be specified in the <configuration>
element of the plugin (see below) or can be passed via the command line.
Examples:
<!- ... ->
<plugin>
<groupId>com.axway.maven.plugins</groupId>
<artifactId>apigw-maven-plugin</artifactId>
<version>{mvn-plugin-ver}</version>
<extensions>true</extensions>
<configuration>
<configPropertyFile>${basedir}/gateway.prop.json</configPropertyFile> <!--(1)-->
<configPropertyFiles> <!--(2)-->
<configPropertyFile>${basedir}/prop-a.json</configPropertyFile>
<configPropertyFile>${basedir}/prop-b.json</configPropertyFile>
</configPropertFiles>
</configuration>
</plugin>
<!- ... ->
-
Location of a configuration file for properties.
-
Location of a list of configuration files for properties.
$ mvn package -Daxway.config.props=a.json -Daxway.config.props.files=b.json,c.json
The plugin includes some Python based scripts to configure environment specific .fed
files.
The scripts can also be used as standalone tools.
The goal apigw:tools
extracts the included script to the ${project.build.directory}/tools
directory.
$ mvn apigw:tools
To create an empty secrets file or to add properties to secrets file, the goal apigw:encrypt
can be used.
A file containing a key is used to initially create the secrets file.
The same key file as used to create the file has to be used to decrypt values.
The key file contains any arbitrary sequence of bytes. It is treated as a binary file.
If you edit this file with a text editor be aware of the encoding and the end of line sequence. In this case use ASCII characters in a single line (no line feed at the end) to prevent any incompatibility with other line end formats or editor encodings.
{
"secrets": { (1)
"__": "3QjoMSfhSelmvMlvcgCdyHf+oTyVnHlyneA3stpN0iQKJ1BUIrY9OA==", (2)
"my.password": "encrypt:changeme", (3)
}
}
-
The
secrets
property is requried. -
Marker to check the passphrase. Don’t delete or change it.
-
The prefix
encrypt:
indicates that the valuechangeme
has to be encrypted by theencrypt
tool.
$ mvn apigw:encrypt -Daxway.config.secrets.file=gateway.crypt.json -Daxway.config.secrets.key=secrets.key
This section provides a short overview of the goals supported by the Maven plugin.
Goal | Description | P[1] | S[2] | D[3] |
---|---|---|---|---|
apigw:init |
Initialize the project. |
yes |
yes |
yes |
apigw:policystudio |
Open PolicyStudio to edit the project. |
yes |
yes |
no |
clean |
Cleanup all generated artifacts. |
yes |
yes |
yes |
package |
Build the archive according to the type of the project. |
yes |
yes |
yes |
install |
Build and install the project archive to the local Maven repository. |
yes |
yes |
yes |
deploy |
Build and deploy the project archive to the remote Maven repository. |
yes |
yes |
yes |
apigw:tools |
Extract the scripts of the configuration tools to the target directory. |
yes |
yes |
yes |
apigw:deploy |
Deploy project to a gateway. |
yes |
yes |
yes |
apigw:encrypt |
Encrypt plain values of secrets file. |
yes |
yes |
yes |