Este conteúdo não está disponível no idioma selecionado.

Chapter 11. Managing Service Registry content using the Maven plug-in


This chapter explains how to manage artifacts stored in the registry using the Service Registry Maven plug-in:

Prerequisites

11.1. Managing artifacts using the Service Registry Maven plug-in

You can use the Service Registry Maven plug-in to upload or download registry artifacts as part of your development build. For example, this plug-in is useful for testing and validating that your schema updates are compatible with client applications.

Registering an artifact using the Maven plug-in

Probably the most common use case for the Maven plug-in is registering artifacts during a build. You can accomplish this by using the register execution goal.

Procedure

  • Update your Maven pom.xml file to use the apicurio-registry-maven-plugin to register an artifact. The following example shows registering an Apache Avro schema:

    <plugin>
      <groupId>io.apicurio</groupId>
      <artifactId>apicurio-registry-maven-plugin</artifactId>
      <version>${registry.version}</version>
      <executions>
        <execution>
          <phase>generate-sources</phase>
          <goals>
            <goal>register</goal> 
    1
    
          </goals>
          <configuration>
            <registryUrl>http://my-cluster-service-registry-myproject.example.com/api</registryUrl> 
    2
    
            <artifactType>AVRO</artifactType>
            <artifacts>
              <schema1>${project.basedir}/schemas/schema1.avsc</schema1> 
    3
    
            </artifacts>
          </configuration>
        </execution>
      </executions>
    </plugin>
    Copy to Clipboard Toggle word wrap
    1
    Specify register as the execution goal to upload the schema artifact to the registry.
    2
    You must specify the Service Registry URL with the /api endpoint.
    3
    You can upload multiple artifacts using the artifact ID and location.

Downloading an artifact using the Maven plug-in

You can also use the Maven plug-in to download artifacts from Service Registry. This is often useful, for example, when generating code from a registered schema.

Procedure

  • Update your Maven pom.xml file to use the apicurio-registry-maven-plugin to download an artifact. The following example shows downloading a single schema by its artifact ID.

    <plugin>
    <groupId>io.apicurio</groupId>
    <artifactId>apicurio-registry-maven-plugin</artifactId>
    <version>${registry.version}</version>
    <executions>
      <execution>
        <phase>generate-sources</phase>
        <goals>
          <goal>download</goal> 
    1
    
        </goals>
        <configuration>
          <registryUrl>http://my-cluster-service-registry-myproject.example.com/api</registryUrl> 
    2
    
          <ids>
            <param1>schema1</param1> 
    3
    
          </ids>
          <artifactExtension>.avsc</artifactExtension> 
    4
    
          <outputDirectory>${project.build.directory}</outputDirectory>
       </configuration>
     </execution>
    </executions>
    </plugin>
    Copy to Clipboard Toggle word wrap
    1
    Specify download as the execution goal.
    2
    You must specify the Service Registry URL with the /api endpoint.
    3
    You can download multiple artifacts to a specified directory using the artifact ID.
    4
    The plug-in automatically tries to select an appropriate file extension, but you can override it using <artifactExtension>.

Testing an artifact using the Maven plug-in

You might want to verify that an artifact can be registered without actually making any changes. This is most often useful when rules are configured in Service Registry. Testing the artifact results in a failure if the artifact content violates any of the configured rules.

Note

Even if the artifact passes the test, no content is added to Service Registry.

Procedure

  • Update your Maven pom.xml file to use the apicurio-registry-maven-plugin to test an artifact. The following example shows testing an Apache Avro schema:

    <plugin>
      <groupId>io.apicurio</groupId>
      <artifactId>apicurio-registry-maven-plugin</artifactId>
      <version>${registry.version}</version>
      <executions>
        <execution>
          <phase>generate-sources</phase>
          <goals>
            <goal>test-update</goal> 
    1
    
          </goals>
          <configuration>
            <registryUrl>http://my-cluster-service-registry-myproject.example.com/api</registryUrl> 
    2
    
            <artifactType>AVRO</artifactType>
            <artifacts>
              <schema1>${project.basedir}/schemas/schema1.avsc</schema1> 
    3
    
            </artifacts>
          </configuration>
        </execution>
      </executions>
    </plugin>
    Copy to Clipboard Toggle word wrap
    1
    Specify test-update as the execution goal to test the schema artifact.
    2
    You must specify the Service Registry URL with the /api endpoint.
    3
    You can test multiple artifacts using the artifact ID and location.

Additional resources

Voltar ao topo
Red Hat logoGithubredditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

Theme

© 2025 Red Hat