Skip to content

Commit

Permalink
Various maven related documentation changes (#964)
Browse files Browse the repository at this point in the history
* re-organized the maven plugin docs a bit and added some info about "test-update" and file extensions

* incorporate feedback from review
  • Loading branch information
EricWittmann authored Oct 29, 2020
1 parent 8bae786 commit 35b2dd1
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 35 deletions.
2 changes: 2 additions & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ endif:getting-started/:[]
* xref:getting-started/assembly-installing-the-registry-openshift.adoc[]
* xref:getting-started/assembly-configuring-the-registry.adoc[]
* xref:getting-started/assembly-managing-registry-artifacts-ui.adoc[]
* xref:getting-started/assembly-managing-registry-artifacts-api.adoc[]
* xref:getting-started/assembly-managing-registry-artifacts-maven.adoc[]
* xref:getting-started/assembly-using-kafka-client-serdes.adoc[]
* xref:getting-started/assembly-using-the-registry-client.adoc[]
* xref:getting-started/assembly-registry-reference.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
include::{mod-loc}shared/all-attributes.adoc[]

[id="managing-registry-artifacts-api"]
= Managing {registry} content using the REST API
= Managing {registry} content using the REST API
//If the assembly covers a task, start the title with a verb in the gerund form, such as Creating or Configuring.

This chapter explains how to manage artifacts stored in the registry using the Registry REST API. This includes using Registry REST API commands, a Maven plug-in, or a Java client application:

* xref:managing-artifacts-using-rest-api[]
* xref:managing-artifacts-using-maven-plugin[]
* xref:managing-artifacts-using-client-code[]

//INCLUDES
include::{mod-loc}getting-started/proc-managing-artifacts-using-rest-api.adoc[leveloffset=+1]
include::{mod-loc}getting-started/proc-managing-artifacts-using-maven-plugin.adoc[leveloffset=+1]
include::{mod-loc}getting-started/proc-managing-artifacts-using-client-code.adoc[leveloffset=+1]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Metadata created by nebel

include::{mod-loc}shared/all-attributes.adoc[]

[id="managing-registry-artifacts-maven"]
= Managing {registry} content using the Maven plug-in

This chapter explains how to manage artifacts stored in the registry using the {registry} Maven plug-in.

* xref:managing-artifacts-using-maven-plugin[]

//INCLUDES
include::{mod-loc}getting-started/proc-managing-artifacts-using-maven-plugin.adoc[leveloffset=+1]
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,111 @@
* {registry} must be installed and running in your environment
* Maven must be installed and configured in your environment

.Procedure
== 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` goal provided. Simply update your Maven `pom.xml` file to use the
`apicurio-registry-maven-plugin` to upload an artifact to {registry}.

The following example shows registering an Apache Avro schema artifact:

. Update your Maven `pom.xml` file to use the `apicurio-registry-maven-plugin` to upload an artifact to {registry}. The following example shows registering an Apache Avro schema artifact:
+
[source,xml]
----
<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>
<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>
----
+
<1> Specify `register` as the execution goal to upload an artifact to the registry.
<2> You must specify the {registry} URL with the `/api` endpoint.
<3> You can upload multiple artifacts using the artifact ID and location.
<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 {registry}. This is often useful, for example, when
generating code from a registered schema.

The following example shows downloading a single schema by its artifact ID.

. You can also update your Maven `pom.xml` file to download a previously registered artifact from {registry}:
+
[source,xml]
----
<plugin>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-registry-maven-plugin</artifactId>
<version>${registry.version}</version>
<executions>
<executions>
<execution>
<phase>generate-sources</phase>
<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>
<ids>
<param1>schema1</param1> <3>
</ids>
<artifactExtension>.avsc</artifactExtension> <4>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</executions>
</plugin>
----
+
<1> Specify `download` as the execution goal.
<2> You must specify the {registry} URL with the `/api` endpoint.
<3> You can download multiple artifacts to a specified directory using the artifact ID.
<4> The plug-in will automatically try to select an appropriate file extension, but you can override it using `<artifactExtension>`.

== Testing an artifact
You may want to simply verify that an artifact can be registered without actually making any changes. This is most
often useful when rules have been configured in {registry}. Testing the artifact will result in a failure if the
artifact content violates any of the configured rules.

NOTE: Even if the artifact passes the test, no content will be added to {registry}.

The following example shows testing an Apache Avro schema artifact:

[source,xml]
----
<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>
----
<1> Specify `test-update` as the execution goal to test an artifact.
<2> You must specify the {registry} URL with the `/api` endpoint.
<3> You can test multiple artifacts using the artifact ID and location.

.Additional resources
* For more details on the Maven plug-in, see https://github.com/Apicurio/apicurio-registry-demo.

0 comments on commit 35b2dd1

Please sign in to comment.