5.2. Maven プラグインを使用したスキーマおよび API アーティファクトのダウンロード
Maven プラグインを使用して Service Registry からアーティファクトをダウンロードできます。これは、たとえば、登録されたスキーマからコードを生成する場合などに便利です。
前提条件
- Service Registry が環境にインストールされ、実行している
手順
Maven pom.xml ファイルを更新して、apicurio-registry-maven-plugin を使用してアーティファクトをダウンロードします。以下の例は、Apache Avro および GraphQL スキーマのダウンロードを示しています。
<plugin>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-registry-maven-plugin</artifactId>
<version>${apicurio.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>download</goal> 1
</goals>
<configuration>
<registryUrl>MY-REGISTRY-URL/apis/registry/v2</registryUrl> 2
<authServerUrl>MY-AUTH-SERVER</authServerUrl>
<clientId>MY-CLIENT-ID</clientId>
<clientSecret>MY-CLIENT-SECRET</clientSecret> 3
<artifacts>
<artifact>
<groupId>TestGroup</groupId> 4
<artifactId>FullNameRecord</artifactId> 5
<file>${project.build.directory}/classes/record.avsc</file>
<overwrite>true</overwrite>
</artifact>
<artifact>
<groupId>TestGroup</groupId>
<artifactId>ExampleAPI</artifactId>
<version>1</version>
<file>${project.build.directory}/classes/example.graphql</file>
<overwrite>true</overwrite>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>-
実行目標として
downloadを指定します。 -
../apis/registry/v2エンドポイントでService Registry URL を指定します。 - 認証が必要な場合は、認証サーバーおよびクライアントの認証情報を指定できます。
-
Service Registry アーティファクトグループ ID を指定します。一意のグループを使用しない場合は、
defaultのグループを指定できます。 - アーティファクト ID を使用すると、複数のアーティファクトを指定したディレクトリーにダウンロードできます。