// Metadata created by nebel
// ParentAssemblies: assemblies/getting-started/as_installing-the-registry.adoc

[id="downloading-artifacts-using-maven-plugin"]
= Downloading schema and API artifacts using the Maven plug-in

[role="_abstract"]
You can use the Maven plug-in to download artifacts from {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 Apache Avro and GraphQL schemas.
+
[source,xml]
----
<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>http://REGISTRY-URL/apis/registry/v2</registryUrl> <2>
          <artifacts>
              <artifact>
                  <groupId>TestGroup</groupId> <3>
                  <artifactId>FullNameRecord</artifactId> <4>
                  <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>
----
<1> Specify `download` as the execution goal.
<2> Specify the {registry} URL with the `../apis/registry/v2` endpoint.
<3> Specify the {registry} artifact group ID. You can specify the `default` group if you do not want to use a unique group.
<4> You can download multiple artifacts to a specified directory using the artifact ID. 

[role="_additional-resources"]
.Additional resources
 * For more details on the {registry} Maven plug-in, see the link:https://github.com/Apicurio/apicurio-registry-demo[Registry demonstration example]
