Plugin Usage

The Apicurio Registry Maven Plugin provides two primary goals:

  • register: Registers an artifact (e.g. Avro schema, OpenAPI document) in the Apicurio Registry. This goal is useful for ensuring that all artifacts required by an application are available in the registry before the application is deployed.
  • download: Downloads an artifact from the Apicurio Registry and makes it available as a local file. This goal is useful for applications that need to dynamically load artifacts from the registry at runtime.

    To use the plugin, you must first configure it in your pom.xml file. Here is a basic example:

    <plugin>
      <groupId>io.apicurio</groupId>
      <artifactId>apicurio-registry-maven-plugin</artifactId>
      <version>${apicurio-registry.version}</version>
      <executions>
        <execution>
          <goals>
            <goal>register</goal>
          </goals>
          <phase>generate-sources</phase>
          <configuration>
            <registryUrl>http://localhost:8080/apis/registry/v3</registryUrl>
            <artifacts>
              <artifact>
                <groupId>ExampleGroup</groupId>
                <artifactId>ExampleArtifact-value</artifactId>
                <artifactType>AVRO</artifactType>
                <file>${project.basedir}/src/main/resources/schemas/greeting.avsc</file>
              </artifact>
            </artifacts>
          </configuration>
        </execution>
      </executions>
    </plugin>

    For more information on configuring the plugin, see the documentation for the individual goals.

  • Register Goal

    The register goal registers an artifact in the Apicurio Registry. It has the following parameters:

    • registryUrl - The URL of the Apicurio Registry.
    • artifactType - The type of the artifact. Valid values are AVRO, JSON, PROTOBUF, and OPENAPI.
    • artifactFile - The file containing the artifact.
    • artifactId - The ID of the artifact.
  • Download Goal

    The download goal downloads an artifact from the Apicurio Registry. It has the following parameters:

    • registryUrl - The URL of the Apicurio Registry.
    • artifactId - The ID of the artifact.
    • outputFile - The file to write the artifact to.