Postman Maven Plugin :: Plugin

A maven plugin to export JAX-RS annotated classes and methods to Postman collection

License

License

Categories

Categories

Maven Build Tools Net
GroupId

GroupId

net.cpollet.maven.plugins
ArtifactId

ArtifactId

postman-maven-plugin
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Postman Maven Plugin :: Plugin
A maven plugin to export JAX-RS annotated classes and methods to Postman collection
Project URL

Project URL

https://github.com/cpollet/postman-maven-plugin

Download postman-maven-plugin

How to add to project

<plugin>
    <groupId>net.cpollet.maven.plugins</groupId>
    <artifactId>postman-maven-plugin</artifactId>
    <version>1.0.0</version>
</plugin>

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.commons : commons-lang3 jar 3.7
io.github.lukehutch : fast-classpath-scanner jar 2.21
javax.ws.rs : javax.ws.rs-api jar 2.1
com.fasterxml.jackson.core : jackson-databind jar 2.9.5
com.fasterxml.jackson.module : jackson-module-jsonSchema jar 2.9.5

provided (5)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.20
org.apache.maven : maven-plugin-api jar 3.5.0
org.apache.maven : maven-core jar 3.5.0
org.apache.maven : maven-artifact jar 3.5.0
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5.1

test (5)

Group / Artifact Type Version
org.apache.maven : maven-compat jar 3.5.0
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 3.3.0
junit : junit jar 4.12
org.assertj : assertj-core jar 3.10.0
org.mockito : mockito-all jar 1.10.19

Project Modules

There are no modules declared in this project.

Build Status Quality Gate Maven Central

Postman Maven Plugin

A maven plugin to export JAX-RS annotated classes and methods to Postman collection.

Usage

Requirements

  • Java 8+
  • Maven 3.5.0+

CLI

In you ~/.m2/settings.xml file, add the following:

<pluginGroups>
  <pluginGroup>net.cpollet.maven.plugins</pluginGroup>
</pluginGroups>

Then, to generates a file ${project.artifactId}-${project.version}.json containing the postman collection in the target folder:

$ mvn postman:generate -Dpostman.packagesToScan=net.cpollet \
                       -Dpostman.baseUrl=http://localhost \
                       -Dpostman.basicAuth.username=username \
                       -Dpostman.basicAuth.password=password

You can execute this command from the jaxrs folder for instance.

  • postman.baseUrl mandatory. A valid URL that will be used as the base URL for all discovered endpoints;
  • postman.packagesToScan optional. If not set, the plugin will scan all packages;
  • postman.basicAuth.* optional.

pom.xml

The CLI equivalent XML configuration is:

<plugin>
    <groupId>net.cpollet.maven.plugins</groupId>
    <artifactId>postman-maven-plugin</artifactId>
    <version>...</version>
    <configuration>
        <packagesToScan> <!-- optional -->
            <value>net.cpollet</value>
            <!-- ... -->
        </packagesToScan>
        <environments>
            <environment>
                <name>default</name>
                <baseUrl>http://localhost</baseUrl>
                <basicAuth> <!-- optional -->
                    <username>username</username>
                    <password>password</password>
                </basicAuth>
            <environment>
            <!-- ... -->
        <environments>
    </configuration>
    <executions> <!-- optional -->
        <execution>
            <id>generate-postman</id>
            <phase>package</package>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The <execution> section is optional, as the plugin binds it's generate goal to the package phase.

Build

$ mvn clean install

Tu run the integration tests, use the run-its profile. Make sure you have the newman-assert and rodolpheche/wiremock docker images:

$ cd newman-assert && build.sh && cd ..
$ docker pull rodolpheche/wiremock

Then:

$ mvn clean install -Prun-its 

Release & Deploy

When gpg: signing failed: Inappropriate ioctl for device, executing export GPG_TTY=$(tty) might help.

Validating before tagging

To validate the checks sonatype executes before tagging, update the pom.xml to remove the -SNAPSHOT. Then, execute

$ mvn clean deploy -Prelease

Actual release

$ mvn clean release:clean release:prepare
$ mvn release:perform

Release from web UI

Versions

Version
1.0.0